/**
 *
 */
package com.ls.lserp.modules.order.service;

import java.awt.image.BufferedImage;
import java.io.*;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.ls.lserp.modules.order.entity.*;
import com.ls.lserp.modules.produce.dao.ProduceLicenseDao;
import com.ls.lserp.modules.produce.dao.ProduceNoticeDao;
import com.ls.lserp.modules.produce.dao.ProducePlanDao;
import com.ls.lserp.modules.produce.entity.ProduceLicense;
import com.ls.lserp.modules.produce.entity.ProduceNotice;
import com.ls.lserp.modules.produce.entity.ProducePlan;
import com.ls.lserp.modules.setting.dao.CheckQualityDao;
import com.ls.lserp.modules.setting.entity.CheckQualityEntity;
import com.ls.lserp.modules.setting.entity.Ognization;
import com.ls.lserp.modules.setting.entity.OperatingEntity;
import com.ls.lserp.modules.sys.utils.UserUtils;


import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.krysalis.barcode4j.impl.code128.Code128Bean;
import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider;
import org.krysalis.barcode4j.tools.UnitConv;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ls.lserp.common.persistence.AjaxDone;
import com.ls.lserp.common.persistence.Page;
import com.ls.lserp.common.service.CrudService;
import com.ls.lserp.modules.order.dao.OrderDao;
import com.ls.lserp.modules.sys.dao.UserDao;
import com.ls.lserp.modules.sys.entity.Dict;
import com.ls.lserp.modules.sys.entity.SendEmailMessage;
import com.ls.lserp.modules.sys.entity.Sequence;
import com.ls.lserp.modules.sys.entity.User;
import com.ls.lserp.modules.sys.utils.DesignoptionUtils;
import com.ls.lserp.modules.sys.utils.DictUtils;
import com.ls.lserp.modules.sys.utils.SequenceUtil;
import com.ls.lserp.modules.common.entity.Material;
import com.ls.lserp.modules.job.entity.OrderSyncJobCache;
import com.ls.lserp.common.utils.DateUtils;
import com.ls.lserp.common.utils.ResourcesUtil;
import com.ls.lserp.common.utils.excel.template.ExcelTemplate;
import com.ls.lserp.dbaccess.Dao.ContractCustomEntityMapper;
import com.ls.lserp.dbaccess.Dao.ContractCustomOrderEntityMapper;
import com.ls.lserp.dbaccess.Dao.OrderEntityMapper;
import com.ls.lserp.dbaccess.Dao.StyleCostEntityMapper;
import com.ls.lserp.dbaccess.Dao.StyleEntityMapper;
import com.ls.lserp.dbaccess.Dao.StyleFitEntityMapper;
import com.ls.lserp.dbaccess.Dao.StyleOptionEntityMapper;
import com.ls.lserp.dbaccess.Entity.ContractCustomEntity;
import com.ls.lserp.dbaccess.Entity.ContractCustomOrderEntity;
import com.ls.lserp.dbaccess.Entity.OrderEntity;
import com.ls.lserp.dbaccess.Entity.StyleDesignHistoryEntity;
import com.ls.lserp.dbaccess.Entity.StyleEntity;
import com.ls.lserp.dbaccess.Entity.StyleFitEntity;
import com.ls.lserp.dbaccess.Entity.StyleMaterialEntity;
import com.ls.lserp.dbaccess.Entity.StyleOptionREntity;
import com.ls.lserp.dbaccess.Entity.StyleQualityControlEntity;


/**
 * 订单
 * @author zq
 * @version 2016-11-16
 */
@Service
@Transactional(readOnly = false)
public class OrderService extends CrudService<OrderDao, Order>{

    @Autowired
    private OrderDao orderDao;
    @Autowired
    private UserDao userDao;
    //生产计划
    @Autowired
    private ProducePlanDao producePlanDao ;
    //生产通知单
    @Autowired
    private ProduceNoticeDao produceNoticeDao;
    //生产制单
    @Autowired
    private ProduceLicenseDao produceLicenseDao;
    // 质检项目设置
    @Autowired
    private CheckQualityDao checkQualityDao ;
    // 合同表
    @Autowired
    private ContractCustomEntityMapper contractCustomEntityMapper;
    // 合同订单关联表
    @Autowired
    private ContractCustomOrderEntityMapper contractCustomOrderEntityMapper;
    // 订单表
    @Autowired
    private OrderEntityMapper orderEntityMapper;
    // 款式费用表
    @Autowired
    private StyleCostEntityMapper styleCostEntityMapper;
    // 款式设计表
    @Autowired
    private StyleOptionEntityMapper styleOptionEntityMapper;
    //
    @Autowired
    private StyleEntityMapper styleEntityMapper;
    //
    @Autowired
    private StyleFitEntityMapper styleFitEntityMapper;
    
    private boolean stopFlag;
		
    /**
     * @Title: findList
     * @Description: 查询
     * @param @param page
     * @param @param Order
     * @param @return
     * @return Page<Order>
     * @throws
     */
    public Page<Order> findList(Page<Order> page, Order order) {
        // 设置分页参数
        order.setPage(page);
        // 执行分页查询
        page.setList(orderDao.findList(order));
        return page;
    }
    
    /**
     * 插入定制单耗信息
     * @param
     * @return
     */
    public void insertExcelData(List<StyleOptionEntity> list,String orderType){
    	if (list!=null && list.size() > 0) {
    		for (int i = 0; i < list.size(); i++) {
				Long materialID = null;
				if (list.get(i).getMaterialCode()!=null&&!"".equals(list.get(i).getMaterialCode())) {
					materialID = orderDao.getMaterialID(list.get(i).getMaterialCode());
					list.get(i).setMaterialID(materialID);
				}
				// 单耗
				if ("".equals(list.get(i).getMaterialUnitCost())||list.get(i).getMaterialUnitCost()==null) {
					list.get(i).setMaterialUnitCost("0");
				}
				// 单耗合计
				if ("".equals(list.get(i).getUnitCostSum())||list.get(i).getUnitCostSum()==null) {
					list.get(i).setUnitCostSum("0");
				}
				// 损耗
				if ("".equals(list.get(i).getMaterialLoss())||list.get(i).getMaterialLoss()==null) {
					list.get(i).setMaterialLoss("0");
				}
				// 换残
				if ("".equals(list.get(i).getChangeImperfect())||list.get(i).getChangeImperfect()==null) {
					list.get(i).setChangeImperfect("0");
				}
				if (ResourcesUtil.getConfig("order_type-type_20").equals(orderType)) {
					list.get(i).setUnitCostSum("1.8");
				}
				list.get(i).preInsert();
				orderDao.insertExcelData(list.get(i));
			}
		}
    }
    /**
     * @throws Exception 
     * @throws ParseException 
     * @Title: insertTempTable
     * @Description:插入关联总表数据
     * @throws
     */
    public void insertTempTable(String orderType) throws Exception{
    	Order order = new Order();
    	order.setBeginDate(DateUtils.getDate("yyyy-MM-dd"));
    	order.setEndDate(DateUtils.getDate("yyyy-MM-dd"));
    	orderDao.insertTempTable (order);
    	if (!ResourcesUtil.getConfig("order_type-type_50").equals(orderType)
    			&& !ResourcesUtil.getConfig("order_type-type_60").equals(orderType)) {
    		StyleOptionEntity styleOptionEntity = new StyleOptionEntity();
    		List<StyleOptionEntity> makeList = makeStyleOptionList(styleOptionEntity);
    		insertExcelData(makeList,orderType);
		}
    }
    /**
     * 得到设计表信息
     * @throws ParseException 
     */
    public void insertStyleNo(String customName,String orderType) throws Exception{
        List<Order> tempList = orderDao.findTemp();
        if (tempList!=null) {
			for (Order orz:tempList) {
				if (orz!=null) {
					//如果订单类型为荷兰大货或日本大货或荷兰小样，则生产号为barCode
					if (ResourcesUtil.getConfig("order_type-type_30").equals(orderType)
							|| ResourcesUtil.getConfig("order_type-type_50").equals(orderType)
							|| ResourcesUtil.getConfig("order_type-type_60").equals(orderType)) {
						orderDao.insertStyleNo(orz.getStyleId(),orz.getStyleBarCode());
						orderDao.insertStyleNoTampTable(orz.getStyleId(),orz.getStyleBarCode());
					}else{
//						if (orz.getStyleMakeType() != null && !"".equals(orz.getStyleMakeType())) {
//							if ("4SMA-4H".equals(orz.getStyleMakeType())||"4SMA-SH".equals(orz.getStyleMakeType())) {
//								Sequence sequence = SequenceUtil.styleNoCloud(customName,"4H");
//								String sequenceCode = sequence.getReturnCode();
//								orderDao.insertStyleNo(orz.getStyleId(),sequenceCode);
//								orderDao.insertStyleNoTampTable(orz.getStyleId(),sequenceCode);
//								orderDao.updateStyleNo(orz.getOrderNO(),sequenceCode);
//								orderDao.updateStyleNoSBU(orz.getOrderNO(),sequenceCode);
//							}else {
//								Sequence sequence = SequenceUtil.styleNoCloud(customName,"4M");
//								String sequenceCode = sequence.getReturnCode();
//								orderDao.insertStyleNo(orz.getStyleId(),sequenceCode);
//								orderDao.insertStyleNoTampTable(orz.getStyleId(),sequenceCode);
//								orderDao.updateStyleNo(orz.getOrderNO(),sequenceCode);
//								orderDao.updateStyleNoSBU(orz.getOrderNO(),sequenceCode);
//							}
//						}
						Sequence sequence = SequenceUtil.orderProductionNo(customName);
						String sequenceCode = sequence.getReturnCode();
						orderDao.insertStyleNo(orz.getStyleId(),sequenceCode);
						orderDao.insertStyleNoTampTable(orz.getStyleId(),sequenceCode);
						orderDao.updateStyleNo(orz.getOrderNO(),sequenceCode);
						orderDao.updateStyleNoSBU(orz.getOrderNO(),sequenceCode);
					}
				}
			}
		}
    }
    
    /**
     * 得到设计表信息
     */
    public List<DesignOption> getdesignList() {
        List<DesignOption> designOptionList = orderDao.getdesignList();
        return designOptionList;
    }
    /**
     * 查询所有数据包括已删除
     * @param order
     * @return
     */

    public List<Order> findAllListExport(Order order) {
        // 执行查询
        List<Order> list = orderDao.findAllListExport(order);
        return list;
    }
    
    /**
     * 获取可导出工序ID集
     * @return
     */
    public List<OperatingEntity> findImportOperatingIdList() {
        // 执行查询
        return orderDao.selectImportOperatingId ();
    }

    /**
     * 获取工序ID集
     * @return
     */
    public List<OperatingEntity> findOperatingIdList() {
        // 执行查询
        return orderDao.selectOperatingId ();
    }
    
    /**
     * 获取订单工序数据集
     * @param order
     * @return
     */
    public List<Order> findOptionValueList(Order order) {
        // 执行查询
        return orderDao.selectOptionValueList (order);
    }
    
    /**
     * 获取订单工序数据集供导出Excel使用
     * @param order
     * @return
     */
    public List<Order> findOptionValueExcelList(Order order) {
        // 执行查询
        return orderDao.selectOpValueExcelList (order);
    }
    
    /**
     * 通过合同ID获取订单集
     * @param order
     * @return
     */
    public List<Order> findOrderList(Order order) {
        // 执行查询
        return orderDao.findOpOrderList(order);
    }
    
    /**
     *  获取工序下量体code
     * @param order
     * @return
     */
    public List<Order> findFitCodeList(Order order) {
        // 执行查询
        return orderDao.selectFitCodeList (order);
    }
    
    /**
     * 导出订单信息
     * @param sk
     * @param order
     * @throws Exception
     */
    public void exportOrder( SXSSFWorkbook sk,Order order) throws Exception {
    	System.out.println("导出工序开始-----"+new Date());
        // 获取可导出工序ID集
        List<OperatingEntity> operatingEntityList = findImportOperatingIdList();
        CellStyle style = sk.createCellStyle();
        //获取订单工序数据集
        List<Order> optinList = new ArrayList<>();
        //获取工序下量体code
        List<Order> fitList = findFitCodeList (order);
        //通过合同ID获取订单集
        List<Order> orderList = findOrderList(order);
        List<StyleOperationtings> solist = new ArrayList<>();
        System.out.println("工序数据处理开始-----"+new Date());
        // 通过工序数量新建sheet页
        for (OperatingEntity operatingEntity: operatingEntityList) {
        	order.setOperatingId(operatingEntity.getOperatingId());
        	optinList = findOptionValueExcelList (order);
        	makeOneSheet(sk,style,operatingEntity,order,optinList,fitList,orderList,solist);
        	System.out.println("工序 "+operatingEntity.getOperatingId()+" 完成--"+new Date());
        }
        System.out.println("工序数据处理结束-----"+new Date());
//        if(contractStatus.equals(ResourcesUtil.getConfig("ORDER_STATUS20"))){
//        	for (int i = 0; i < solist.size(); i++) {
//				if (solist.get(i)!=null) {
//					orderDao.insertStyleOperationtings(solist.get(i));
//				}
//			}
//            orderDao.updateCustomContractStatus(contractId,ResourcesUtil.getConfig("ORDER_STATUS30"));
//        }
    }
    
    /**
     * 获取片数
     * @param styleId
     * @return
     */
    private Integer getPartsSum(long styleId){
    	return orderDao.selectSum (styleId);
    }
    
    /**
     * 获取订单量体数据
     * @param styleId
     * @return
     */
    private Order getFitValue(long styleId){
    	return orderDao.selectFitValue (styleId);
    }
    
    /**
     * 制作一个sheet页
     * @param sk
     * @param style
     * @param operatingEntity
     * @param order
     * @param optinList
     * @param fitList
     * @param orderList
     * @param solist
     * @throws Exception 
     */
    public void makeOneSheet(SXSSFWorkbook sk,CellStyle style,OperatingEntity operatingEntity,Order order
    		,List<Order> optinList,List<Order> fitList,List<Order> orderList,List<StyleOperationtings> solist) throws Exception{
        order.setOperatingId (operatingEntity.getOperatingId ());
        // 根据工序ID查询项目名称
        int labelLength = orderDao.labelList (order);
        int cellCount = 0;
        // 新建sheet，sheet名称为工序名称
        Sheet sheet = sk.createSheet (operatingEntity.getValueNameCn ());
        // 每个sheet页里项目名称生成
        Row row = sheet.createRow (0);
        Cell cell = row.createCell (0);
        cell.setCellValue ("No.");
        cell.setCellStyle (changeCellStyle (sk, true, style));
        Cell cell1 = row.createCell (1);
        cell1.setCellValue ("订单号");
        cell1.setCellStyle (changeCellStyle (sk, true, style));
        Cell cell2 = row.createCell (2);
        cell2.setCellValue ("生产号");
        cell2.setCellStyle (changeCellStyle (sk, true, style));
        // cell下标
        int cellIndexTemp = 3;
        // 特殊项目处理：设置表头名称
        Map<String,Object> mapList = operatingSpecailItem(sk,style,operatingEntity,optinList,null,null,cellIndexTemp,row,cell,"specail_ItemName","","","");
        cellIndexTemp = (int)mapList.get("cellCount");
    	row = (Row)mapList.get("row");
    	cell = (Cell)mapList.get("cell");
        //量体标题
        for (Order oTemp : fitList) {
			if (oTemp.getOperatingId() == operatingEntity.getOperatingId ()) {
				row.createCell (cellIndexTemp);
				row.getCell(cellIndexTemp).setCellValue (oTemp.getFitNameCn());
				row.getCell (cellIndexTemp).setCellStyle (changeCellStyle (sk, true, style));
				cellIndexTemp++;
			}
		}
        //定制项目标题
        for (int i = 0; i < optinList.size (); i++) {
            if (operatingEntity.getOperatingId () == optinList.get (i).getOperatingId () && cellCount < labelLength) {
                Cell cellOther = row.createCell (cellIndexTemp);
                cellOther.setCellValue (optinList.get (i).getItemNameCn ());
                cellOther.setCellStyle (changeCellStyle (sk, true, style));
                cellIndexTemp++;
                cellCount++;
            }
        }
        Cell cell10 = row.createCell (cellIndexTemp);
        cell10.setCellValue ("主料");
        cell10.setCellStyle (changeCellStyle (sk, true, style));
        // 设置cell数据
        setCellValue(sk,operatingEntity,optinList,fitList,orderList,sheet,cellIndexTemp);
    }
    /**
     * 设置cell数据
     * @param sk
     * @param operatingEntity
     * @param optinList
     * @param fitList
     * @param orderList
     * @param sheet
     * @param cellIndexTemp
     * @throws Exception
     */
    public void setCellValue(SXSSFWorkbook sk,OperatingEntity operatingEntity,List<Order> optinList
    		,List<Order> fitList,List<Order> orderList,Sheet sheet,int cellIndexTemp) throws Exception{
    	Row row = sheet.getRow(0);
    	Cell cell = row.getCell (0);
        int count = 1;
        int cellCount = 4;
        Order orderTemp;
        //一条订单区分
        String oneFlag = "";
        if (orderList.size() == 1) {
        	oneFlag = "false";
		}else{
			oneFlag = "true";
		}
        for (int i = 0; i < optinList.size (); i++) {
            if (operatingEntity.getOperatingId () == optinList.get (i).getOperatingId ()) {
                if ((i != 0 && !optinList.get (i).getOrderNO ().equals (optinList.get (i - 1).getOrderNO ()) )|| i == 0 || "false".equals(oneFlag)) {
                	oneFlag = "true";
                    row = sheet.createRow (count);
                    row.setHeight ((short) 1050);
                    cell = row.createCell (0);
                    cell.setCellValue (String.valueOf (count));
                    cell = row.createCell (1);
                    cell.setCellValue (optinList.get (i).getOrderNO ());
                    cell = row.createCell (2);
                    cell.setCellValue (optinList.get (i).getStyleNo ());
                    count++;
                    orderTemp = getFitValue (optinList.get (i).getStyleId ());
                    String fitItemValue[] = orderTemp.getFitItemValue ().split (",");
                    String fitValue[] = orderTemp.getFitValue ().split (",");
                    cellCount = 3;
                    // 特殊项目处理：设置cell数据
                    Map<String,Object> mapList = operatingSpecailItem(sk,null,operatingEntity,optinList,optinList.get (i),orderTemp,cellCount,row,cell,"specail_ItemValue","","","");
                    cellCount = (int)mapList.get("cellCount");
                	row = (Row)mapList.get("row");
                	cell = (Cell)mapList.get("cell");
                    //量体数据
                    for (Order oTemp : fitList) {
        				if (oTemp.getOperatingId() == operatingEntity.getOperatingId ()) {
        					for (int y = 0; y < fitItemValue.length; y++) {
								if (fitItemValue[y].equals(oTemp.getFitValue())) {
									row.createCell (cellCount).setCellValue (fitValue[y]);
                                    cellCount++;
								}
							}
        				}
        			}
                    cell = row.createCell (cellIndexTemp);
                    cell.setCellValue (optinList.get (i).getStyleFabricNo ());
                }
                cell = row.createCell (cellCount++);
                cell.setCellValue (optinList.get (i).getOptionValue ());
                cell.setCellType (HSSFCell.CELL_TYPE_STRING);
            }
        }
    }
    
    /**
     * 工序特殊项目处理方法合并方法
     * 
     * @param sk 制作Excel表格基本工具类
     * @param style 表格样式
     * @param operatingEntity 工序类
     * @param optinList 订单工序数据集合
     * @param optinData 单条订单工序数据
     * @param orderTemp 订单量体数据
     * @param cellCount 计数器
     * @param row excel行
     * @param cell excel单元格
     * @param operationCode 工序项目编码
     * @param operationValue 工序项目数据值
     * @param operationRemarks 工序项目备注数据
     * @param callFlag 调用该方法的来源区分： 
     * 1.'specail_ItemName'设置标题名称
     * 2.'specail_ItemValue' 设置单元格数据
     * 3.'specail_OperatingData' 拼接工序表数据
     * @throws Exception
     */
    public Map<String,Object> operatingSpecailItem(SXSSFWorkbook sk,CellStyle style,OperatingEntity operatingEntity
    		,List<Order> optinList,Order optinData,Order orderTemp,int cellCount,Row row,Cell cell,String callFlag
    		,String operationCode,String operationValue,String operationRemarks) throws Exception{
    	Map<String,Object> mapList = new HashMap<>();
    	Integer partsSum = 0;
    	// 裁剪生产
        if (operatingEntity.getOperatingId () == 3) {
        	if ("specail_ItemName".equals(callFlag)) {
        		cell = row.createCell (cellCount++);
        		cell.setCellValue ("衬衫规格");
        		cell.setCellStyle (changeCellStyle (sk, true, style));
        		cell = row.createCell (cellCount++);
        		cell.setCellValue ("看订单算片");
        		cell.setCellStyle (changeCellStyle (sk, true, style));
			}else if ("specail_ItemValue".equals(callFlag)){
				// 衬衫规格
				cell = row.createCell (cellCount++);
				if (optinData.getSizeCD().split("-").length > 1) {
					cell.setCellValue (optinData.getSizeCD().split("-")[1]);
				}else {
					cell.setCellValue ("");
				}
				//看订单算片
				partsSum = getPartsSum(optinData.getStyleId ());
				cell = row.createCell (cellCount++);
				if (partsSum == null) {
					partsSum = 0;
				}
				cell.setCellValue (partsSum);
			}else if ("specail_OperatingData".equals(callFlag)){
				// 衬衫规格
                operationCode = operationCode + "4SIZE" +",";
                if (optinData.getSizeCD()!= null && optinData.getSizeCD().split("-").length > 1) {
                	operationValue = operationValue +String.valueOf(optinData.getSizeCD().split("-")[1])+",";
                } else {
                    operationValue = operationValue +",";
                }
                partsSum = getPartsSum(optinData.getStyleId ());
                if (partsSum == null) {
                	partsSum = 0;
                }
                //看订单算片
                operationCode =  operationCode + "see_order_sum" +",";
                operationValue = operationValue + String.valueOf(partsSum) +",";
			}
        // 卡领子 订小号 夹牙绳
        } else if (operatingEntity.getOperatingId () == 18) {
        	if ("specail_ItemName".equals(callFlag)) {
        		cell = row.createCell (cellCount++);
                cell.setCellValue ("型号");
                cell.setCellStyle (changeCellStyle (sk, true, style));
        	}else if ("specail_ItemValue".equals(callFlag)){
        		String[] sizCodeItem = orderTemp.getSizeCD ().split ("-");
        		cell = row.createCell (cellCount++);
        		if (sizCodeItem.length > 1) {
        			cell.setCellValue (sizCodeItem[1]);
        		}else {
        			cell.setCellValue ("");
        		}
        	}else if ("specail_OperatingData".equals(callFlag)){
        		String[] sizCodeItem = orderTemp.getSizeCD ().split ("-");
                if (sizCodeItem.length > 1) {
                	operationValue = operationValue + sizCodeItem[1]+",";
				}else {
					operationValue = operationValue +",";
				}
                operationCode =  operationCode + "4SIZE" +",";
        	}
        // 订兜
        } else if (operatingEntity.getOperatingId () == 23) {
        	if ("specail_ItemName".equals(callFlag)) {
        		cell = row.createCell (cellCount++);
                cell.setCellValue ("衬衫规格");
                cell.setCellStyle (changeCellStyle (sk, true, style));
        	}else if ("specail_ItemValue".equals(callFlag)){
        		if (optinData.getSizeCD()!=null) {
        			cell = row.createCell (cellCount++);
        			if (optinData.getSizeCD()!= null && optinData.getSizeCD().split("-").length >1) {
        				cell.setCellValue (optinData.getSizeCD().split("-")[1]);
        			} else {
        				cell.setCellValue ("");
        			}
        		}
        	}else if ("specail_OperatingData".equals(callFlag)){
        		if (optinData.getSizeCD()!=null) {
                    operationCode =  operationCode + "4SIZE" +",";
                    if (optinData.getSizeCD()!= null && optinData.getSizeCD().split("-").length >1) {
                        operationValue = operationValue + optinData.getSizeCD().split("-")[1]+",";
                    } else {
                        operationValue = operationValue +",";
                    }
				}
        	}
        // 半袖袖口
        } else if (operatingEntity.getOperatingId () == 98) {
        	if ("specail_ItemName".equals(callFlag)) {
        		cell = row.createCell (cellCount++);
                cell.setCellValue ("衬衫规格");
                cell.setCellStyle (changeCellStyle (sk, true, style));
        	}else if ("specail_ItemValue".equals(callFlag)){
        		if (optinData.getSizeCD()!=null) {
        			cell = row.createCell (cellCount++);
        			if (optinData.getSizeCD()!= null && optinData.getSizeCD().split("-").length >1) {
        				cell.setCellValue (optinData.getSizeCD().split("-")[1]);
        			} else {
        				cell.setCellValue ("");
        			}
        		}
        	}else if ("specail_OperatingData".equals(callFlag)){
        		if (optinData.getSizeCD()!=null) {
                    operationCode =  operationCode + "4SIZE" +",";
                    if (optinData.getSizeCD()!= null && optinData.getSizeCD().split("-").length >1) {
                        operationValue = operationValue + optinData.getSizeCD().split("-")[1]+",";
                    } else {
                        operationValue = operationValue +",";
                    }
				}
        	}
        //扣
        }else if (operatingEntity.getOperatingId () == 16) {
        	if ("specail_ItemName".equals(callFlag)) {
                cell = row.createCell (cellCount++);
                cell.setCellValue ("大扣数");
                cell.setCellStyle (changeCellStyle (sk, true, style));
                cell = row.createCell (cellCount++);
                cell.setCellValue ("小扣数");
                cell.setCellStyle (changeCellStyle (sk, true, style));
                cell = row.createCell (cellCount++);
                cell.setCellValue ("扣眼数");
                cell.setCellStyle (changeCellStyle (sk, true, style));
                
        	}else if ("specail_ItemValue".equals(callFlag)){
        		//扣数
        		if ("4SBU".equals(optinData.getItemValue())) {
        			// 大扣数
        			cell = row.createCell (cellCount++);
        			if (optinData.getOptionCost1 () != null) {
        				cell.setCellValue (optinData.getOptionCost1 ().split(",")[1]);
        			}
        			// 小口数
        			cell = row.createCell (cellCount++);
        			if (optinData.getOptionCost1 () != null) {
        				cell.setCellValue (optinData.getOptionCost1 ().split(",")[0] + " ( " + optinData.getOptionCost1 ().split(",")[2] + ")");
        			}	
        		}
        		//扣眼数
        		for (int j = 0; j < optinList.size(); j++) {
        			if (optinList.get(j).getStyleId() == optinData.getStyleId() 
        					&& "4THN2".equals(optinList.get (j).getItemValue())
        					&& optinList.get (j).getOperatingId() == 16) {
        				cell = row.createCell (cellCount++);
        				cell.setCellValue (optinList.get(j).getRemarks());
        			}
        		}
        	}else if ("specail_OperatingData".equals(callFlag)){
        		if ("4SBU".equals(optinData.getItemValue())) {
                    // 大扣数
					if (optinData.getOptionCost1 () != null) {
						operationCode =  operationCode + "big_button_sum" +",";
						operationValue = operationValue + optinData.getOptionCost1 ().split(",")[1]+",";
					} else {
						operationValue = operationValue +",";
					}
                    // 小口数
                    operationCode =  operationCode + "small_button_sum" +",";
                    if (optinData.getOptionCost1 ()!= null) {
                        operationValue = operationValue + ((int)Double.parseDouble(optinData.getOptionCost1 ().split(",")[0]) - (int)Double.parseDouble(optinData.getOptionCost1 ().split(",")[2]))+",";
                    } else {
                        operationValue = operationValue +",";
                    }
                }
            	//扣眼数
        		for (int j = 0; j < optinList.size(); j++) {
					if (optinList.get(j).getStyleId() == optinData.getStyleId() 
							&& "4THN2".equals(optinList.get (j).getItemValue())
							&& optinList.get (j).getOperatingId() == 16) {
						operationRemarks = optinList.get(j).getRemarks();
					}
				}
        	}
        //扣前牌
        }else if (operatingEntity.getOperatingId () == 83) {
        	if ("specail_ItemName".equals(callFlag)) {
            	cell = row.createCell (cellCount++);
                cell.setCellValue ("扣半袖袖口");
                cell.setCellStyle (changeCellStyle (sk, true, style));
        	}else if ("specail_ItemValue".equals(callFlag)){
        		for (int j = 0; j < optinList.size(); j++) {
        			if (optinList.get(j).getStyleId() == optinData.getStyleId() 
        					&& "4SSL".equals(optinList.get (j).getItemValue())
        					&& optinList.get (j).getOperatingId() == 83) {
        				//如果袖子为4SLSH1,4SLSH2其中一个，则显示
        				if ("4SLSH1,4SLSH2".indexOf(optinList.get (j).getOptionValue().split("/")[0]) != -1) {
        					cell = row.createCell (cellCount++);
        					cell.setCellValue (optinList.get(j).getOptionValue());
        				}else {
        					cell = row.createCell (cellCount++);
        					cell.setCellValue ("");
        				}
        			}
        		}
        	}else if ("specail_OperatingData".equals(callFlag)){
        		for (int j = 0; j < optinList.size(); j++) {
					if (optinList.get(j).getStyleId() == optinData.getStyleId() 
							&& "4SSL".equals(optinList.get (j).getItemValue())
							&& optinList.get (j).getOperatingId() == 83) {
						//如果袖子为4SLSH1,4SLSH2其中一个，则显示
						if ("4SLSH1,4SLSH2".indexOf(optinList.get (j).getOptionValue()) != -1) {
							operationCode =  operationCode + optinList.get(j).getItemValue() +",";
							operationValue = operationValue + optinList.get (j).getOptionValue()+",";
						}else {
							operationCode =  operationCode + optinList.get(j).getItemValue() +",";
							operationValue = operationValue + ",";
						}
					}
				}
        	}
        }else if ("specail_OperatingData".equals(callFlag) && operatingEntity.getOperatingId () == 91) {
        	//扣数
    		for (int j = 0; j < optinList.size(); j++) {
				if (optinList.get(j).getStyleId() == optinData.getStyleId() 
						&& "4SBU".equals(optinList.get (j).getItemValue())
						&& optinList.get (j).getOperatingId() == 91) {
					operationRemarks = optinList.get(j).getOptionCost();
					if (optinList.get(j).getOptionCost1().split(",").length == 3) {
						operationRemarks = new BigDecimal(optinList.get(j).getOptionCost()).subtract(new BigDecimal(optinList.get(j).getOptionCost1().split(",")[2])).toString();
						//如果袖头数据包含'HMBU',则总数加2
						for (int k = 0; k < optinList.size(); k++) {
							if (optinList.get(k).getStyleId() == optinData.getStyleId() 
									&& "4SCU".equals(optinList.get (k).getItemValue())
									&& optinList.get (k).getOperatingId() == 91) {
						        if (optinList.get(k).getOptionValue().indexOf("HMBU") != -1) {
						        	operationRemarks = new BigDecimal(operationRemarks).add(new BigDecimal(2)).toString();
								}
							}
						}
					}
				}
			}
        }
        mapList.put("sk", sk);
    	mapList.put("cellCount", cellCount);
    	mapList.put("row", row);
    	mapList.put("cell", cell);
    	mapList.put("operationCode", operationCode);
    	mapList.put("operationValue", operationValue);
    	mapList.put("operationRemarks", operationRemarks);
        return mapList;
    }
    
    /**
     * 
     * @param operatingEntity
     * @param optinList
     * @param fitList
     * @param orderList
     * @return
     * @throws Exception 
     */
    public List<StyleOperationtings> makeOperatingList(OperatingEntity operatingEntity,List<Order> optinList,List<Order> fitList
    		,List<Order> orderList) throws Exception{
    	List<StyleOperationtings> solist = new ArrayList<>();
    	StyleOperationtings  sot = new StyleOperationtings();
        int flg = 0;
        Order orderTemp;
        // 合同ID
        Long contractId = 0L;
        //订单ID
        Long  orderId = 0L;
        //款式ID
        Long  styleId = 0L;
        //生产号
        String styleNo = "";
        //条形码
        String  styleBarCode = "";
        //工序ID
        Long  operationItmeId = 0L;
        //工序VALUE
        String operationValue = "";
        //工序CODE
        String operationCode = "";
        //工序REMARKS
        String operationRemarks = "";
        //工序状态
        String operatingStatus = "";
        //一条订单区分
        String oneFlag = "";
        if (orderList.size() == 1) {
        	oneFlag = "false";
		}else{
			oneFlag = "true";
		}
        for (int i = 0; i < optinList.size (); i++) {
            if (operatingEntity.getOperatingId () == optinList.get (i).getOperatingId ()) {
                if ((i != 0 && !optinList.get (i).getOrderNO ().equals (optinList.get (i - 1).getOrderNO ()) )|| i == 0 || "false".equals(oneFlag)) {
                    if(!operationValue.equals("") ){
                        //工序CODE
                        sot.setOperationCode(operationCode);
                        //工序VALUE
                        sot.setOperationValue(operationValue);
                        sot.setRemarks(operationRemarks);
                        sot.preInsert();
                        solist.add(sot);
                        sot = new StyleOperationtings();
                        operationValue = "";
                        operationCode = "";
                        flg = 0;
                    }
                }
            }
            if (operatingEntity.getOperatingId () == optinList.get (i).getOperatingId ()) {
                if ((i != 0 && !optinList.get (i).getOrderNO ().equals (optinList.get (i - 1).getOrderNO ()) )|| i == 0 || "false".equals(oneFlag)) {
                	oneFlag = "true";
                    //订单ID
                    orderId = optinList.get (i).getId();
                    sot.setOrderId(orderId);
                    //款式ID
                    styleId = optinList.get(i).getStyleId();
                    sot.setStyleId(styleId);
                    //生产号
                    styleNo = optinList.get(i).getStyleNo();
                    sot.setStyleNo(styleNo);
                    //工序ID
                    operationItmeId = operatingEntity.getOperatingId () ;
                    sot.setOperationItmeId(operationItmeId);
                    //条形码
                    styleBarCode = String.valueOf(optinList.get(i).getStyleBarCode());
                    sot.setStyleBarCode(styleBarCode);
                    //合同ID
                    contractId = Long.valueOf(optinList.get(i).getContractID());
                    sot.setContractID(contractId);
                    //工序状态
                    operatingStatus = ResourcesUtil.getConfig("OPERATING_STATUS00");
                    sot.setOperatingStatus(operatingStatus);
                    orderTemp = getFitValue (optinList.get (i).getStyleId ());
                    String fitItemValue[] = orderTemp.getFitItemValue ().split (",");
                    String fitValue[] = orderTemp.getFitValue ().split (",");
                    // 特殊项目处理：准备数据 供 插入工序表使用
                    Map<String,Object> mapList = operatingSpecailItem(null,null,operatingEntity,optinList,optinList.get (i),orderTemp,0,null,null,"specail_OperatingData",operationCode,operationValue,operationRemarks);
                	operationCode = (String)mapList.get("operationCode");
                	operationValue = (String)mapList.get("operationValue");
                	operationRemarks = (String)mapList.get("operationRemarks");
                    //量体数据
                    for (Order oTemp : fitList) {
        				if (oTemp.getOperatingId() == operatingEntity.getOperatingId ()) {
        					for (int y = 0; y < fitItemValue.length; y++) {
								if (fitItemValue[y].equals(oTemp.getFitValue())) {
									operationCode =  operationCode + fitItemValue[y] +",";
                                    operationValue = operationValue + fitValue[y]+",";
								}
							}
        				}
        			}
                }
                operationCode =  operationCode + optinList.get(i).getItemValue() +",";
                if(optinList.get (i).getOptionValue () != null) {
                	operationValue = operationValue + optinList.get (i).getOptionValue () +",";
                } else {
                    operationValue = operationValue +",";
                }
            }
        }
        flg = 2;
        if (flg != 0) {
            if(!"".equals(operationValue)) {
                //工序CODE
                sot.setOperationCode(operationCode);
                //工序VALUE
                sot.setOperationValue(operationValue);
                sot.setRemarks(operationRemarks);
                sot.preInsert();
                solist.add(sot);
                sot = new StyleOperationtings();
                operationValue = "";
                operationCode = "";
                flg = 0;
            }
        }
        return solist;
    }
    
    /**
     * excel cell样式
     */
    private CellStyle changeCellStyle(SXSSFWorkbook sk,boolean colorFlg,CellStyle style) {
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setLeftBorderColor(IndexedColors.GREEN.getIndex());
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setRightBorderColor(IndexedColors.BLUE.getIndex());
        style.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);
        style.setTopBorderColor(IndexedColors.BLACK.getIndex());
        if (colorFlg) {
            Font font = sk.createFont();
            font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
            style.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());
            style.setFillPattern(CellStyle.SOLID_FOREGROUND);
            style.setFont (font);
        } else {
            style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
        }
        return style;
    }

    //生成条码文件至临时目录，并返回生成图片的路径信息
    public  String makeBarcode( String barcodeValue){
        //存放条码图片的路径
        final String barcodePicPath = "d:\\\\barcode\\\\";
        try {
            //Create the barcode bean
            Code128Bean bean = new Code128Bean ();


            final int dpi = 150;

            //Configure the barcode generator
            bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); //makes the narrow bar
            //width exactly one pixel
            bean.doQuietZone(false);

            //Open output file
            File outputFile = new File(barcodePicPath+barcodeValue+".png");
            OutputStream out = new FileOutputStream (outputFile);
            try {
                //Set up the canvas provider for monochrome JPEG output
                BitmapCanvasProvider canvas = new BitmapCanvasProvider(
                        out, "image/png", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);

                //Generate the barcode
                bean.generateBarcode(canvas, barcodeValue);

                //Signal end of generation
                canvas.finish();
            } finally {
                out.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return barcodePicPath+barcodeValue+".png";
    }
    /**
     * 打印设计相关信息
     * @param tempFilePath
     * @param order
     * @param handle
     * @throws IOException
     */
    private void printDesignInfo(String tempFilePath, Order order, ExcelTemplate handle, String itemName, String itemValue) throws IOException {
        // 变量声明
        List<String> dataCellDeclare = new ArrayList<String>();
        // 变量值集合
        List<Map<String,Object>> dataList = new  ArrayList<Map<String,Object>>();
        dataCellDeclare.add(itemName);
        dataCellDeclare.add(itemValue);
        // 从数据库返回的结果集
        List<Order> resultList = new ArrayList();
        // 如果是配料信息
        if (itemName.equals("mixName")) {
            resultList = this.orderDao.exportMixInfo(order);
        } else {
            resultList = this.orderDao.exportDesignOptionByOrderId(order);
        }
        // 临时接收变量
        Order tempBean;
        for (int i = 0; i < resultList.size(); i++) {
            // 结果
            Map<String,Object> map = new HashMap<String, Object>();
            tempBean = resultList.get(i);
            map.put(itemName, tempBean.getItemName());
            map.put(itemValue, tempBean.getItemValue());
            dataList.add(map);
        }
        // 向excel表输出
        handle.writeListData(tempFilePath, dataCellDeclare, dataList, 0);
    }

    /**
     * 打印量体跟试穿信息
     * @param tempFilePath
     * @param orderFitList
     * @param handle
     * @throws IOException
     */
    private void prinFitInfo(String tempFilePath, List<FitProperty> orderFitList, ExcelTemplate handle) throws IOException {
        // 变量声明
        List<String> dataCellDeclare = new ArrayList<String>();
        // 变量值集合
        List<Map<String,Object>> dataList = new  ArrayList<Map<String,Object>>();
        dataCellDeclare.add("fitName");
        dataCellDeclare.add("fitValue");
        // 结果
        Map<String,Object> map;
        // 临时接收变量
        FitProperty tempBean;
        for (int i = 0; i < orderFitList.size(); i++) {
            map = new HashMap<String, Object>();
            tempBean = orderFitList.get(i);
            map.put("fitName", tempBean.getPropertyNameEn() + "/" + tempBean.getPropertyNameCn());
            map.put("fitValue", tempBean.getFitValue());
            dataList.add(map);
        }
        // 向excel表输出
        handle.writeListData(tempFilePath, dataCellDeclare, dataList, 0);
    }
    /**
     * 打印订单基本信息
     * @throws IOException
     */
    private List<FitProperty> printOrderBaseInfo(String tempFilePath, Order order, ExcelTemplate handle) throws IOException {

        // 变量声明
        List<String> dataCellDeclare = new ArrayList<String>();
        // 变量值
        Map<String,Object> dataMapResult = new  HashMap<String, Object>();

        // 订单号
        dataCellDeclare.add("orderNO");
        dataMapResult.put("orderNO", order.getOrderNO());

        // 交期重要
        dataCellDeclare.add("URGENT_CD");

        // 正常
        if (ResourcesUtil.getConfig("order_flag-normal_10").equals(order.getUrgentCD())) {
            dataMapResult.put("URGENT_CD", "normal/正常");
        }
        // 加急
        else {
            dataMapResult.put("URGENT_CD", "express/加急");
        }

        // 款式类别
        dataCellDeclare.add("styleCategoryCD");
        Dict dictStyleCatetory = DictUtils.getDictEntity(order.getStyleCategoryCD());
        dataMapResult.put("styleCategoryCD", dictStyleCatetory.getItemNameEn() + "/" + dictStyleCatetory.getItemNameCn());

        // 订单日期
        dataCellDeclare.add("orderDate");
        dataMapResult.put("orderDate", order.getOrderDate());

        // 量体样衣
        // 原始数据
        dataCellDeclare.add("tryOnOrder");
        List<FitProperty> orderFitList = this.orderDao.findFitInFoListByOrderId(order);

        // 判断之前的数据是净量体的还是试穿数据
        // 净量体个数
        int fitFlagCount = 0;

        // 遍历量体信息
        for (int i = 0; i < orderFitList.size(); i++) {
            // 净量体数据
            if (ResourcesUtil.getConfig("fit_use_type-fit_type_10").equals(orderFitList.get(i).getFitUseTypeCd())) {
                fitFlagCount ++;
            }
        }

        // 如果所有项目都是净量体项目，则说明此次数据是“量体”页面数据，否则则是“试穿”页面数据
        if (fitFlagCount == orderFitList.size()) {
            // 量体页面:无结果
            dataMapResult.put("tryOnOrder", ResourcesUtil.getConfig("order_export_no_answer"));
        } else {
            // 试穿页面
            // 尺码组
            Dict dictSizeGroup = DictUtils.getDictEntity(order.getSizeGroupCD());
            // 尺码
            Dict dictSize = DictUtils.getDictEntity(order.getSizeCD());
            if (StringUtils.isBlank(dictSizeGroup.getItemNameEn())) {
                // 量体页面:无结果
                dataMapResult.put("tryOnOrder", ResourcesUtil.getConfig("order_export_no_answer"));
            } else {
                // 尺码显示
                dataMapResult.put("tryOnOrder", dictSizeGroup.getItemNameEn() + "/" + dictSize.getItemNameEn() + "/" + dictSizeGroup.getItemNameCn() + "/" + dictSize.getItemNameCn() );
            }

        }

        // 面料品号
        dataCellDeclare.add("fabricCode");
        if (order.getMaterial()!=null){
            if (StringUtils.isEmpty(order.getMaterial().getMaterialCode())) {
                // 无结果
                dataMapResult.put("fabricCode", ResourcesUtil.getConfig("order_export_no_answer"));
            } else {
                // 正常显示
                //dataMapResult.put("fabricCode", order.getMaterial().getMaterialCode());
            }
        }else{
            dataMapResult.put("fabricCode", ResourcesUtil.getConfig("order_export_no_answer"));
        }


        // 客户名称
        dataCellDeclare.add("customerName");
        if (StringUtils.isEmpty(order.getCustomerName())) {
            // 无结果
            dataMapResult.put("customerName", ResourcesUtil.getConfig("order_export_no_answer"));
        } else {
            // 正常显示
            dataMapResult.put("customerName", order.getCustomerName());
        }


        // 特殊订单
        dataCellDeclare.add("specialOrder");
        if (StringUtils.isEmpty(order.getSpecialOder())) {
            // 无结果
            dataMapResult.put("specialOrder", ResourcesUtil.getConfig("order_export_no_answer"));
        } else {
            // 正常显示
            dataMapResult.put("specialOrder", order.getSpecialOder());
        }

        // 面料成份
        dataCellDeclare.add("fabricComposition");

        // 店名
        dataCellDeclare.add("shopName");
        if (StringUtils.isEmpty(order.getShopName())) {
            // 无结果
            dataMapResult.put("shopName", ResourcesUtil.getConfig("order_export_no_answer"));
        } else {
            // 正常显示
            dataMapResult.put("shopName", order.getShopName());
        }

        // 发货目的地(暂无结果显示)
        // 幅宽
        dataCellDeclare.add("shippingDestination");
        if (StringUtils.isEmpty(order.getShippingDestintion())) {
            // 无结果
            dataMapResult.put("shippingDestination", ResourcesUtil.getConfig("order_export_no_answer"));
        } else {
            // 正常显示
            dataMapResult.put("shippingDestination", order.getShippingDestintion());
        }


        // 幅宽
        dataCellDeclare.add("fabricWidth");

        //船期 (暂无结果显示)
        dataCellDeclare.add("shipmentsDate");
        // 正常显示
        dataMapResult.put("shipmentsDate", order.getOrderShipmentsDate());
        // 缝制
        dataCellDeclare.add("makeType");

        //String makeType = orderDao.selectMakeType();
        // 衬衫身型
        dataCellDeclare.add("shirtMode");

        // 标题
        dataCellDeclare.add("titleName");
        dataMapResult.put("titleName", dictStyleCatetory.getItemNameEn() + ":" + dictStyleCatetory.getItemNameCn());

        // 向excel表输出
        handle.writeData(tempFilePath, dataCellDeclare, dataMapResult, 0);

        return orderFitList;
    }

    /**
     * 根据订单查询设计信息
     * @param order
     * @return
     */
    public List<DesignOption> findDesignOptionByOrderId(Order order) {
        return this.orderDao.findDesignOptionByOrderId(order);
    }

    /**
     * 根据订单查询设计信息
     * @param order
     * @return
     */
    public List<DesignOption> findDesignOption(Order order) {
        return this.orderDao.findDesignOption(order);
    }

    /**
     *根据面料ID查找面料信息
     * @param order
     * @return
     */
    public Material searchInfoByMaterialId(Order order) {

        try {

            List<Material> resultList = this.orderDao.searchInfoByMaterialId(order);
            if (resultList != null && resultList.size() > 0) {
                return resultList.get(0);
            } else {
                return null;
            }

        } catch (Exception e) {

            e.printStackTrace();
            return null;

        }

    }

    /**
     * 根据订单查询设计信息（配料）
     * @param order
     * @return
     */
    public List<DesignOption> findDesignOptionMaterialByOrderId(Order order) {

        return this.orderDao.findDesignOptionMaterialByOrderId(order);

    }
    
    /**
     * 获取品控信息 
     * @return
     */
    public List<StyleOptionEntity> findQualityControl() {

        return orderDao.findQualityControl();

    }


    /**
     * 查询单个订单
     * @return
     */
    public Order findOrder(Order order) {

        // 主表
        List<Order> orderList = orderDao.findListExport(order);
        order = orderList.get(0);

        return order;
    }
    /**
     * 获取面料信息
     * @param fabricCode
     * @return
     */
    public Material getMaterialInfo(String fabricCode){

        return orderDao.getMaterialInfo(fabricCode);
    }
    
    /**
     * 制作单耗list供导出用
     * @param styleOptionEntity
     * @return
     * @throws Exception 
     */
    public List<StyleOptionEntity> makeStyleOptionList(StyleOptionEntity styleOptionEntity) throws Exception{
    	String customOrderNO = "";
    	String materialCode = "";
    	String exceptionStr = "nomalException";
    	try {
	        styleOptionEntity.setUpdateDate(new Date());
	    	List<StyleOptionEntity> styleOptionList = new ArrayList<StyleOptionEntity>();
	    	List<StyleOptionEntity> styleOptionIDList = orderDao.findStyleIDList(styleOptionEntity);
	    	for(StyleOptionEntity optionEntity:styleOptionIDList){
	    		//System.out.println(optionEntity.getContractNo());
	    		customOrderNO = optionEntity.getCustomOrderNO();
	    		materialCode = optionEntity.getMaterialCode();
	    		styleOptionEntity.setStyleID(optionEntity.getStyleID());
	    		StyleOptionEntity styleOption = new StyleOptionEntity();
	    		//订单面料为自带面料
	    		if (optionEntity.getMaterialSource() == 1) {
	    			styleOption = orderDao.getStyleCustomInfo(styleOptionEntity);
	    		//库存面料
				}else {
					styleOption = orderDao.getStyleInfo(styleOptionEntity);
				}
	    		//StyleOptionEntity styleOption2 = new StyleOptionEntity();
	    		//try {
	    		if (styleOption == null) {
	    			exceptionStr = "materialNotExsit";
	    			styleOption = new StyleOptionEntity();
	    		}
	    		BigDecimal materialUnitCost = new BigDecimal(0); 
	    		if ("小样面料".equals(optionEntity.getStyleNameCn())) {
	    			materialUnitCost = new BigDecimal(optionEntity.getRemarks());
	    			styleOption.setMaterialLoss("0");
				}else {
					materialUnitCost = orderDao.getMaterialUnitCost(optionEntity);
					if (materialUnitCost == null) {
						materialUnitCost = new BigDecimal(0);
					}
					styleOption.setMaterialLoss("0.0816");
				}
	    		styleOption.setMaterialUnitCost(materialUnitCost+"");
	    		styleOption.setUnitCostSum(materialUnitCost.multiply(new BigDecimal(1).add(new BigDecimal(0.0816))) + "");
				//} catch (Exception e) {
				//	exceptionStr += "订单号为 " + customOrderNO + " 的 " + materialCode + " 物料不存在\n";
				//	continue;
				//}
	    		styleOptionList.add(styleOption);
	    		/*styleOption2.setStyleID(styleOption.getStyleID());
	    		styleOption2.setMaterialUnitCost("1");
	    		styleOption2.setMaterialCode(styleOption.getMaterialComposition());
	    		styleOption2.setItemValue("FabricComposition");
	    		styleOptionList.add(styleOption2);*/
	    		List<StyleOptionEntity> OptionList = orderDao.findStyleUnitCost(styleOptionEntity);
	    		for(StyleOptionEntity sOption:OptionList){
	    			if ("4COFO".equals(sOption.getItemValue())) {
	    				sOption.setMaterialUnitCost("1");
					}else if ("4CALB".equals(sOption.getItemValue())) {
						if ("100CO-CA00572".equals(sOption.getOptionValue())) {
							sOption.setMaterialUnitCost("2");
						}else {
							sOption.setMaterialUnitCost("1");
						}
					//商标,遇到特殊商标如'ATELIER MUNRO-214 / DYO-217',按"/"分开存入
					}else if (sOption.getItemValue().indexOf("LP") != -1) {
						sOption.setMaterialUnitCost("1");
						String lpStr = sOption.getOptionValue().replace("/", ",");
						if (lpStr.split(",").length > 1) {
							StyleOptionEntity sOptionCloneLP = sOption.clone();
							sOption.setMaterialCode(lpStr.split(",")[0].trim());
							sOptionCloneLP.setMaterialCode(lpStr.split(",")[1].trim());
							styleOptionList.add(sOptionCloneLP);
						}
					//如果为扣，则特殊计算
					}else if ("4SBU".equals(sOption.getItemValue())) {
						if (sOption.getOptionCost1() != null && sOption.getOptionCost1().split(",").length == 3) {
							//小扣数
							String smallBtnCount = sOption.getOptionCost1().split(",")[0].trim();
							//大扣数
							sOption.setMaterialUnitCost(sOption.getOptionCost1().split(",")[1].trim());
							//大小扣分开保存，且小扣加'-S'与大扣区分开。
							if (!"0".equals(smallBtnCount)) {
								StyleOptionEntity sOptionClone = sOption.clone();
								sOptionClone.setMaterialCode(sOption.getOptionValue() + "-S");
								sOptionClone.setMaterialUnitCost(smallBtnCount);
								styleOptionList.add(sOptionClone);
							}
						}
					}
	    			styleOptionList.add(sOption);
	    		}
	    	}
	    	//throw new RuntimeException("订单号为 " + customOrderNO + " 的 " + materialCode + " 物料不存在");
    		return styleOptionList;
		} catch (Exception e) {
			logger.error(e.getMessage(),e);
			if ("materialNotExsit".equals(exceptionStr)) {
				throw new RuntimeException("订单号为 " + customOrderNO + " 的 " + materialCode + " 物料不存在");
			}else {
				throw new RuntimeException("订单导入失败，请联系系统管理员！");
			}
		}
    }
    
    /**
     * 单耗导出时重新计算单耗
     * @param msg
     * @return
     * @throws ParseException 
     */
    public void countUnitCostAgain(StyleOptionEntity styleOptionEntity){
    	String flag = "false";
    	Long sameFlag = null;
    	StyleOptionEntity sOptionEntity = null;
    	List <StyleOptionEntity> sizeUnitCostList = findSizeUnitCost ();
    	//获取指定合同下订单的单耗数据
    	List<StyleMaterialEntity> styleMaterialList = orderDao.findStyleMaterial(styleOptionEntity);
    	if (styleMaterialList != null && styleMaterialList.size() > 0) {
			for (StyleMaterialEntity sEntity : styleMaterialList) {
				//面料
				if (sEntity.getItemValue() == null || "".equals(sEntity.getItemValue())) {
					StyleOptionEntity optionEntity = new StyleOptionEntity();
					optionEntity.setStyleID(sEntity.getStyleId());
					BigDecimal materialUnitCost = orderDao.getMaterialUnitCost(optionEntity);
		    		if (materialUnitCost == null) {
		    			materialUnitCost = new BigDecimal(0);
					}
					sEntity.setMaterialCost(materialUnitCost);
					sEntity.setMaterialPreLoss(new BigDecimal("0.0816"));
					sEntity.setMaterialChangeimperfect(new BigDecimal(0));
					sEntity.setMaterialUnitExpend(materialUnitCost.multiply(new BigDecimal(1).add(new BigDecimal(0.0816))));
					flag = "true";
				/*//面料成分
				}else if ("FabricComposition".equals(sEntity.getItemValue())) {
					sEntity.setMaterialCost(new BigDecimal(1));
					sEntity.setMaterialPreLoss(new BigDecimal(0));
					sEntity.setMaterialChangeimperfect(new BigDecimal(0));
					sEntity.setMaterialUnitExpend(new BigDecimal(1));
					flag = "true";*/
				//扣
				}else if ("4SBU".equals(sEntity.getItemValue())) {
					StyleDesignHistoryEntity cloudEntity = new StyleDesignHistoryEntity();
					//通过款式ID获取和计算扣有关的数据
					List<StyleOptionREntity> sList = orderDao.findInfoAboutSBU(sEntity.getStyleId());
					if (sList != null && sList.size() > 0) {
						for (StyleOptionREntity sREntity : sList) {
							// 领子
							if ("4SCO".equals(sREntity.getItemValue())) {
								cloudEntity.setModelSco(sREntity.getOptionValue());
							//袖开祺
							}else if ("4SSV".equals(sREntity.getItemValue())) {
								cloudEntity.setModelSsv(sREntity.getOptionValue());
							//袖头
							}else if ("4SCU".equals(sREntity.getItemValue())) {
								cloudEntity.setModelScu(sREntity.getOptionValue());
							//前立
							}else if ("4SFP".equals(sREntity.getItemValue())) {
								cloudEntity.setModelSfp(sREntity.getOptionValue());
							//后衣长
							}else {
								String[] itemValue = sREntity.getItemValue().split(",");
								String[] fitValue = sREntity.getOptionValue().split(",");
								for (int i = 0; i < itemValue.length; i++) {
									if (ResourcesUtil.getConfig("LENGTITEM02").equals(itemValue[i])) {
										cloudEntity.setSizeLen(fitValue[i]);
									}else if (ResourcesUtil.getConfig("POSTUITEM08").equals(itemValue[i])) {
										cloudEntity.setSizeBof(fitValue[i]);
									}
								}
							}
						}
					}
					if ("N-41".equals(sEntity.getMaterialName())) {
						System.out.println("距离");
					}
					
					Map<String, Object> map = countSbuNum(cloudEntity,sizeUnitCostList);
					//小扣数
					String smallSbu = map.get("smallSbu").toString();
					//大扣数
					String bigSbu = map.get("bigSbu").toString();
					//领子扣数
					String scoBtn = map.get("scoCost").toString();
					//扣数备注
					String remarkStr = map.get("remarkStr").toString();
					if (sEntity.getMaterialName().indexOf("-S") != -1) {
						sEntity.setMaterialCost(new BigDecimal(smallSbu));
						sEntity.setMaterialUnitExpend(new BigDecimal(smallSbu));
					}else {
						sEntity.setMaterialCost(new BigDecimal(bigSbu));
						sEntity.setMaterialUnitExpend(new BigDecimal(bigSbu));
					}
					sEntity.setMaterialPreLoss(new BigDecimal(0));
					sEntity.setMaterialChangeimperfect(new BigDecimal(0));
					sEntity.setRemarks(remarkStr);
					flag = "true";
					if (!sEntity.getStyleId().equals(sameFlag)) {
						sameFlag = sEntity.getStyleId();
						sOptionEntity = new StyleOptionEntity();
						sOptionEntity.preInsert();
						sOptionEntity.setStyleID(sEntity.getStyleId());
						sOptionEntity.setMaterialUnitCost(new BigDecimal(smallSbu).add(new BigDecimal(bigSbu)).toString());
						sOptionEntity.setOptionCost1(smallSbu + "," + bigSbu + "," + scoBtn);
						sOptionEntity.setRemarks(remarkStr);
						//orderDao.updateOptionSBUCount(sOptionEntity);
					}
				//小号	
				}else if ("4SIZELB".equals(sEntity.getItemValue())) {
					sEntity.setMaterialCost(new BigDecimal(1));
					sEntity.setMaterialPreLoss(new BigDecimal(0));
					sEntity.setMaterialChangeimperfect(new BigDecimal(0));
					sEntity.setMaterialUnitExpend(new BigDecimal(1));
					flag = "true";
				//商标
				}else if (sEntity.getItemValue().indexOf("LP0") != -1 || "4COFO".equals(sEntity.getItemValue())) {
					sEntity.setMaterialCost(new BigDecimal(1));
					sEntity.setMaterialPreLoss(new BigDecimal(0));
					sEntity.setMaterialChangeimperfect(new BigDecimal(0));
					sEntity.setMaterialUnitExpend(new BigDecimal(1));
					flag = "true";
				//洗涤标
				}else if ("4CALB".equals(sEntity.getItemValue())) {
					sEntity.setMaterialPreLoss(new BigDecimal(0));
					sEntity.setMaterialChangeimperfect(new BigDecimal(0));
					if ("100CO-CA00572".equals(sEntity.getMaterialName())) {
						sEntity.setMaterialCost(new BigDecimal(2));
						sEntity.setMaterialUnitExpend(new BigDecimal(2));
					}else {
						sEntity.setMaterialCost(new BigDecimal(1));
						sEntity.setMaterialUnitExpend(new BigDecimal(1));
					}
				//配料
				}else if ("4SCON".equals(sEntity.getItemValue())||"4THN1".equals(sEntity.getItemValue())||"4SBI".equals(sEntity.getItemValue())||"4RIBB".equals(sEntity.getItemValue())) {
					sEntity.setMaterialCost(new BigDecimal(0));
					sEntity.setMaterialPreLoss(new BigDecimal(0));
					sEntity.setMaterialChangeimperfect(new BigDecimal(0));
					sEntity.setMaterialUnitExpend(new BigDecimal(0));
					flag = "true";
				}
				if ("true".equals(flag)) {
					sEntity.preInsert();
					//orderDao.updateStyleMaterial(sEntity);
				}
			}
		}
    }
    
    /**
     * 制作单耗list供导出用
     * @param styleOptionEntity
     * @param msg
     * @return
     * @throws ParseException 
     */
    public StyleOptionEntity makeOptionList(StyleOptionEntity styleOptionEntity,String msg) throws ParseException{
    	// 单耗重新计算
    	// 如果从未导入过单耗，则重新计算
    	//if (styleOptionEntity.getUnitCostStatus() == 0) {
    		countUnitCostAgain(styleOptionEntity);
		//}
    	
    	List<StyleOptionEntity> styleOptionIDList = orderDao.findUnitCostList(styleOptionEntity);
    
    	//总料
    	List<StyleOptionEntity> styleOptionList = new ArrayList<StyleOptionEntity>();
    	//原料
    	List<StyleOptionEntity> styleOptionFabricList = new ArrayList<StyleOptionEntity>();
    	//扣
    	List<StyleOptionEntity> styleOptionSBUList = new ArrayList<StyleOptionEntity>();
    	//洗涤标
    	List<StyleOptionEntity> styleOptionCALBList = new ArrayList<StyleOptionEntity>();
    	//商标
    	List<StyleOptionEntity> styleOptionLPList = new ArrayList<StyleOptionEntity>();
    	//小号
    	List<StyleOptionEntity> styleOptionSIZELBList = new ArrayList<StyleOptionEntity>();
    	//辅料
    	List<StyleOptionEntity> styleOptionSCONList = new ArrayList<StyleOptionEntity>();
    	//Long styleID = null;
    	for(StyleOptionEntity optionEntity:styleOptionIDList){
    		StyleOptionEntity optionEnt = new StyleOptionEntity();
    		optionEnt.setInsideOrderNO(optionEntity.getInsideOrderNO());
    		optionEnt.setCustomOrderNO(optionEntity.getCustomOrderNO());
    		optionEnt.setStyleCategoryCN(optionEntity.getStyleCategoryCN());
    		optionEnt.setItemNameCn(optionEntity.getItemNameCn());
    		optionEnt.setMaterialCode(optionEntity.getMaterialCode());
    		optionEnt.setMaterialName(optionEntity.getMaterialName());
    		optionEnt.setMaterialSpec(optionEntity.getMaterialSpec());
    		optionEnt.setMaterialUnitCost(optionEntity.getMaterialUnitCost());
    		optionEnt.setMaterialLoss(optionEntity.getMaterialLoss());
    		optionEnt.setChangeImperfect(optionEntity.getChangeImperfect());
    		optionEnt.setUnitCostSum(optionEntity.getUnitCostSum());
    		optionEnt.setRemarks(optionEntity.getRemarks());
    		optionEnt.setItemValue(optionEntity.getItemValue());
    		optionEnt.setOptionCost1(optionEntity.getOptionCost1());
    		if ("".equals(optionEnt.getItemValue())||optionEnt.getItemValue()==null) {
    			//styleID = optionEntity.getStyleID();
    			optionEnt.setItemNameCn(msg);
    		}else {
    			if ("FabricComposition".equals(optionEnt.getItemValue())) {
    				optionEnt.setItemNameCn("标牌_面料成分");
    			}else if("4SBU".equals(optionEnt.getItemValue())){
    				/*optionEnt.setBigBtnNum(optionEnt.getOptionCost1().split(",")[1]);
    				optionEnt.setSmallBtnNum(optionEnt.getOptionCost1().split(",")[0]);*/
    				optionEnt.setItemNameCn("扣号");
    			}
    			//optionEnt.setInsideOrderNO("");
    			//optionEnt.setCustomOrderNO("");
    			optionEnt.setStyleCategoryCN("");
    		}
    		styleOptionList.add(optionEnt);
    	}
    	//Long styleIDLp = null;
    	//Long styleIDScon = null;
    	for(StyleOptionEntity optionEntity:styleOptionIDList){
    		if (optionEntity.getItemValue()==null) {
    			optionEntity.setItemValue("");
			}
    		if ("".equals(optionEntity.getItemValue())) {
    			optionEntity.setItemNameCn(msg);
    			styleOptionFabricList.add(optionEntity);
    		}else if ("4SBU".equals(optionEntity.getItemValue())) {
    			/*optionEntity.setBigBtnNum(optionEntity.getOptionCost1().split(",")[1]);
    			optionEntity.setSmallBtnNum(optionEntity.getOptionCost1().split(",")[0]);*/
    			optionEntity.setItemNameCn("扣号");
    			styleOptionSBUList.add(optionEntity);
    		}else if ("4CALB".equals(optionEntity.getItemValue())) {
    			styleOptionCALBList.add(optionEntity);
    		}else if ("4COFO".equals(optionEntity.getItemValue())||"LP".equals(optionEntity.getItemValue().substring(0, 2))||"FabricComposition".equals(optionEntity.getItemValue())) {
    			if ("FabricComposition".equals(optionEntity.getItemValue())) {
    				//styleIDLp = optionEntity.getStyleID();
    				optionEntity.setItemNameCn("标牌_面料成分");
        		}else {
        			optionEntity.setInsideOrderNO("");
        			optionEntity.setCustomOrderNO("");
        			optionEntity.setStyleCategoryCN("");
        		}
    			styleOptionLPList.add(optionEntity);
    		}else if ("4SIZELB".equals(optionEntity.getItemValue())) {
    			styleOptionSIZELBList.add(optionEntity);
    		}else if ("4SCON".equals(optionEntity.getItemValue())||"4THN1".equals(optionEntity.getItemValue())||"4SBI".equals(optionEntity.getItemValue())||"4RIBB".equals(optionEntity.getItemValue())) {
    			if (!"4THN1".equals(optionEntity.getItemValue())) {
    				//styleIDScon = optionEntity.getStyleID();
    				optionEntity.setInsideOrderNO("");
    				optionEntity.setCustomOrderNO("");
    				optionEntity.setStyleCategoryCN("");
        		}
    			styleOptionSCONList.add(optionEntity);
    		}
    	}
    	styleOptionEntity.setStyleOptionList(styleOptionList);
    	styleOptionEntity.setStyleOptionFabricList(styleOptionFabricList);
    	styleOptionEntity.setStyleOptionCALBList(styleOptionCALBList);
    	styleOptionEntity.setStyleOptionLPList(styleOptionLPList);
    	styleOptionEntity.setStyleOptionSIZELBList(styleOptionSIZELBList);
    	styleOptionEntity.setStyleOptionSBUList(styleOptionSBUList);
    	styleOptionEntity.setStyleOptionSCONList(styleOptionSCONList);
        return styleOptionEntity;
    }
    
    /**
	 * 导出走货明细
	 * @return
	 */
	public List<TransportGoodsDetail> exportTGDetail(TransportGoodsDetail transportGoodsDetail){
		transportGoodsDetail.preInsert();
		return orderDao.exportTGDetail(transportGoodsDetail);
	}
	
    /**
     * 获取定制费用明细信息
     * @param styleId
     * @return
     */
    public List<StyleCostEntity> findStyleCostList(Long styleId){
    	List<StyleCostEntity> newEntities = new ArrayList<>();
    	List<StyleCostEntity> costEntities = orderDao.findStyleCostList(styleId);
    	for (int i = 0; i < costEntities.size(); i++) {
			if ("0.00000".equals(costEntities.get(i).getCostValue().toString())) {
				continue;
			}
			newEntities.add(costEntities.get(i));
		}
        return newEntities ;
    }
    
    /**
     * 获取单耗
     * @return
     */
    public List<StyleOptionEntity> findSizeUnitCost(){

        return orderDao.findSizeUnitCost();
    }

    /**
     * excel数据插入
     * @param styleList
     * @param orderList
     * @return
     * @throws Exception
     */
    public Long insertExcelData (List<BigcargoStyle> styleList, List<Order> orderList, List<OrderTempTableEntity> orderTempTableEntityList,
    		String venderSimpleName,Long venderID,String orderType,String dataSourceFlag,Date targetDateMTM,String orderDate) throws Exception {
    	System.out.println("定制导入开始-------------"+new Date());
    	Order order = new Order();
        // 工序类
        StyleOperationtings operatingEntity = new StyleOperationtings();
        // 工序数据集
        List<StyleOperationtings> operatingDataList = new ArrayList<>();
        // 工序ID集
        List<OperatingEntity> operatingIdList = findOperatingIdList();
        BigcargoStyle bigcargoStyle;
        BarCode barCode;
        BarCode barCode2;
        OrderTempTableEntity orderTempTableEntity;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        CustomizationContract customizationContract = new CustomizationContract();
        ProduceLicense produceLicense = new ProduceLicense();
        long userId = 1;
        //
        long sshirtShopId = Long.parseLong(ResourcesUtil.getConfig("sshirt_shopId"));
        if ("ERP".equals(dataSourceFlag)) {
        	userId = UserUtils.getUser().getId();
		}else if("MTM".equals(dataSourceFlag)){
			orderType = ResourcesUtil.getConfig ("order_type-type_20");
		}
        Date shipDate4M = SequenceUtil.getShipTime("4M");
        String styleNo4M = SequenceUtil.getKeyWord("4M");
        Date shipDate4H = SequenceUtil.getShipTime("4H");
        String styleNo4H = SequenceUtil.getKeyWord("4H");
        //新合同区分
        String newContractFlag = "false";
        //制作方法区分
        String makeType = "";
        //机缝订单数量
        int MQuantity = 0;
        //手缝订单数量
        int HQuantity = 0;
        //机缝标记
        String MFlag = "false";
        //手缝标记
        String HFlag = "false";
        //生产计划
        ProducePlan producePlan = new ProducePlan();
        ProducePlan producePlan_M = new ProducePlan();
        ProducePlan producePlan_H = new ProducePlan();
        //生产通知单
        ProduceNotice produceNotice = new ProduceNotice();
        //机缝
        ProduceNotice produceNotice_M = new ProduceNotice();
        //手缝
        ProduceNotice produceNotice_H = new ProduceNotice();
        //日期格式化
        GregorianCalendar gc = new GregorianCalendar();
        gc.setTime(new Date());
        gc.add(5, 4);
        // 订单表插入
        if (orderList!=null) {
	        	customizationContract.preInsert();
	        	customizationContract.setCreateBy(new User());
	        	customizationContract.getCreateBy().setId(userId);
	        	customizationContract.setContractNO(SequenceUtil.contractCode(venderSimpleName, "sequence_customizationContract", 4).getReturnCode());
	        	customizationContract.setVenderID(venderID);
	        	customizationContract.setOrderTypeCD(orderType);
	        	customizationContract.setContractIssueDate(simpleDateFormat.parse(DateUtils.getDate("yyyy-MM-dd")));
	        	customizationContract.setContractCurrencyCD("QUOTATION_CURRENCY-USD");
	        	customizationContract.setContractExchangeRate(new BigDecimal("6.7"));
	        	customizationContract.setContractTransportMode("TRANSPORT_MODE-AIR_TRANSPORT");
	        	if ("ERP".equals(dataSourceFlag)) {
	        		customizationContract.setContractDeliveryDate(shipDate4M);
		        	customizationContract.setContractDeliveryHDate(shipDate4H);
	    		}else if("MTM".equals(dataSourceFlag)){
	    			customizationContract.setContractDeliveryDate(targetDateMTM);
		        	customizationContract.setContractDeliveryHDate(null);
	    		}
	        	customizationContract.setContractAuditStatus(ResourcesUtil.getConfig("reserver_meterial_ok"));
	        	customizationContract.setRemarks(ResourcesUtil.getConfig("enchaseInfo_complete_none"));
	        	if ("MTM".equals(dataSourceFlag)) {
	        		customizationContract.setCartonInfoStatus(1);
	        		customizationContract.setRemarks(ResourcesUtil.getConfig("enchaseInfo_complete_all"));
	    		}
	        	//设置 合同状态 为 生产中
	        	customizationContract.setOrderStatus(ResourcesUtil.getConfig("Workshop_30"));
	        	// erp同步状态
	        	customizationContract.setContractSyncStatus(0);
	        	// 日本大货 和 荷兰小样自定义日期
	        	if (ResourcesUtil.getConfig("order_type-type_50").equals(orderType)
	        			|| ResourcesUtil.getConfig("order_type-type_60").equals(orderType)) {
	        		customizationContract.setContractIssueDate(DateUtils.parseDate(orderDate));
	        		customizationContract.setCreateDate(DateUtils.parseDate(orderDate));
	        		customizationContract.setContractSyncStatus(1);
				}
	        	orderDao.insertContract(customizationContract);
	        	//创建生产计划
            	if ("ORDER_TYPE-TYPE_10".equals(orderType)) {
            		producePlan_M.setPlanNO("P." + venderSimpleName + ".M." + styleNo4M);
            		producePlan_M = producePlanDao.getPlanByNo(producePlan_M);
            		producePlan_H.setPlanNO("P." + venderSimpleName + ".H." + styleNo4H);
            		producePlan_H = producePlanDao.getPlanByNo(producePlan_H);
            		if (producePlan_M == null) {
            			/*-------------------------------- M 机缝生产计划-----------------------------*/
            			producePlan_M = new ProducePlan();
            			//创建一条生产计划
            			producePlan_M.setPlanNO("P." + venderSimpleName + ".M." + styleNo4M);
            			producePlan_M.setOgnizationID(venderID);
            			producePlan_M.preInsert();
            			producePlan_M.setUserGroupID(27L);
            			producePlan_M.setPlanBeginDate(simpleDateFormat.parse(DateUtils.getDate("yyyy-MM-dd")));
            			producePlan_M.setPlanEndDate(gc.getTime());
            			producePlan_M.setPlanNumber(20);
            			producePlan_M.setPlanEfficiency(new BigDecimal(3));
            			producePlan_M.setPlanPeriod(new BigDecimal(4));
            			producePlan_M.setPlanStatus(1);
            			producePlan_M.setPlanQuantity(new BigDecimal(0));
            			producePlanDao.insert(producePlan_M);
            			/*-------------------------------- H 手缝生产计划-----------------------------*/ 
            			producePlan_H = new ProducePlan();
            			//创建一条生产计划
            			producePlan_H.setPlanNO("P." + venderSimpleName + ".H." + styleNo4H);
            			producePlan_H.setOgnizationID(venderID);
            			producePlan_H.preInsert();
            			producePlan_H.setUserGroupID(27L);
            			producePlan_H.setPlanBeginDate(simpleDateFormat.parse(DateUtils.getDate("yyyy-MM-dd")));
            			producePlan_H.setPlanEndDate(gc.getTime());
            			producePlan_H.setPlanNumber(20);
            			producePlan_H.setPlanEfficiency(new BigDecimal(3));
            			producePlan_H.setPlanPeriod(new BigDecimal(4));
            			producePlan_H.setPlanStatus(1);
            			producePlan_H.setPlanQuantity(new BigDecimal(0));
            			producePlanDao.insert(producePlan_H);
					}
            	//非荷兰定制订单正常创建生产计划和生产通知单   
				}else if (!"ORDER_TYPE-TYPE_10".equals(orderType)) {
		            	//创建一条生产计划
		            	producePlan.setPlanNO("P." + customizationContract.getContractNO());
		            	producePlan.setOgnizationID(venderID);
		            	producePlan.preInsert();
		            	producePlan.setUserGroupID(27L);
		            	producePlan.setPlanQuantity(new BigDecimal(0));
		            	producePlan.setPlanBeginDate(simpleDateFormat.parse(DateUtils.getDate("yyyy-MM-dd")));
		            	producePlan.setPlanEndDate(gc.getTime());
		            	producePlan.setPlanNumber(20);
		            	producePlan.setPlanEfficiency(new BigDecimal(3));
		            	producePlan.setPlanPeriod(new BigDecimal(4));
		            	producePlan.setPlanStatus(1);
		            	producePlanDao.insert(producePlan);
		            }
        	int count = 0;
            int orderLen = orderList.size();
            for (int i = 0; i < orderLen; i++) {
                order = new Order();
                bigcargoStyle = new BigcargoStyle();
                barCode = new BarCode();
                barCode2 = new BarCode();
                orderTempTableEntity = new OrderTempTableEntity();
                //荷兰订单合同特殊处理
                if ("ORDER_TYPE-TYPE_10".equals(orderType)) {
                	if ("4SMA-4M,4SMA-BM,4SMA-SM".indexOf(styleList.get(i).getStyleMakeType()) != -1) {
                		if ("false".equals(MFlag)) {
                			//创建一条生产通知单
                			produceNotice_M.setNoticeNO("N.M." + customizationContract.getContractNO());
                        	produceNotice_M.setContractID(customizationContract.getId());
                        	produceNotice_M.setOgnizationID(venderID);
                        	produceNotice_M.preInsert();
                        	produceNotice_M.setUserGroupID(27L);
                        	produceNotice_M.setNoticeQuantity(new BigDecimal(0));
                        	produceNotice_M.setNoticeBeginDate(producePlan_M.getPlanBeginDate());
                        	produceNotice_M.setNoticeEndDate(producePlan_M.getPlanEndDate());
                        	produceNotice_M.setNoticeNumber(producePlan_M.getPlanNumber());
                        	produceNotice_M.setNoticeEfficiency(producePlan_M.getPlanEfficiency());
                        	produceNotice_M.setNoticePeriod(producePlan_M.getPlanPeriod());
                        	produceNotice_M.setNoticeFlag("1");
                        	produceNotice_M.setMaterialStatus(1);
                        	produceNotice_M.setRemarks(DateUtils.formatDate(shipDate4M, "yyyy-MM-dd"));
                        	produceNoticeDao.insert(produceNotice_M);
                        	//创建一条生产通知单和生产计划关联数据
                        	produceNotice_M.setPlanID(producePlan_M.getId());
                        	produceNoticeDao.insertPlanNotice(produceNotice_M);
                        	//创建通知单，设置标记为true
                        	MFlag = "true";
						}
                		makeType = "M";
                		MQuantity++;
					}else {
                		if ("false".equals(HFlag)) {
                			//创建一条生产通知单
                			produceNotice_H.setNoticeNO("N.H." + customizationContract.getContractNO());
                        	produceNotice_H.setContractID(customizationContract.getId());
                        	produceNotice_H.setOgnizationID(venderID);
                        	produceNotice_H.preInsert();
                        	produceNotice_H.setUserGroupID(27L);
                        	produceNotice_H.setNoticeQuantity(new BigDecimal(0));
                        	produceNotice_H.setNoticeBeginDate(producePlan_H.getPlanBeginDate());
                        	produceNotice_H.setNoticeEndDate(producePlan_H.getPlanEndDate());
                        	produceNotice_H.setNoticeNumber(producePlan_H.getPlanNumber());
                        	produceNotice_H.setNoticeEfficiency(producePlan_H.getPlanEfficiency());
                        	produceNotice_H.setNoticePeriod(producePlan_H.getPlanPeriod());
                        	produceNotice_H.setNoticeFlag("1");
                        	produceNotice_H.setMaterialStatus(1);
                        	produceNotice_H.setRemarks(DateUtils.formatDate(shipDate4H, "yyyy-MM-dd"));
                        	produceNoticeDao.insert(produceNotice_H);
                        	//创建一条生产通知单和生产计划关联数据
                        	produceNotice_H.setPlanID(producePlan_H.getId());
                        	produceNoticeDao.insertPlanNotice(produceNotice_H);
                        	//创建通知单，设置标记为true
                        	HFlag = "true";
						}
                		makeType = "H";
                		HQuantity++;
					}
                //非荷兰订单
				}else {
					if ("false".equals(MFlag)) {
						//创建一条生产通知单
		            	produceNotice.setNoticeNO("N." + customizationContract.getContractNO());
		            	produceNotice.setContractID(customizationContract.getId());
		            	produceNotice.setOgnizationID(venderID);
		            	produceNotice.preInsert();
		            	produceNotice.setUserGroupID(27L);
		            	produceNotice.setNoticeQuantity(new BigDecimal(0));
		            	produceNotice.setNoticeBeginDate(simpleDateFormat.parse(DateUtils.getDate("yyyy-MM-dd")));
		            	produceNotice.setNoticeEndDate(gc.getTime());
		            	produceNotice.setNoticeNumber(20);
		            	produceNotice.setNoticeEfficiency(new BigDecimal(3));
		            	produceNotice.setNoticePeriod(new BigDecimal(4));
		            	produceNotice.setNoticeFlag("1");
		            	produceNotice.setMaterialStatus(1);
		            	if ("ERP".equals(dataSourceFlag)) {
		            		produceNotice.setRemarks(DateUtils.formatDate(shipDate4M, "yyyy-MM-dd")  + " / " + DateUtils.formatDate(shipDate4H, "yyyy-MM-dd"));
			    		}else if("MTM".equals(dataSourceFlag)){
				        	produceNotice.setRemarks(DateUtils.formatDate(targetDateMTM, "yyyy-MM-dd"));
			    		}
		            	produceNoticeDao.insert(produceNotice);
		            	//创建一条生产通知单和生产计划关联数据
		            	produceNotice.setPlanID(producePlan.getId());
		            	produceNoticeDao.insertPlanNotice(produceNotice);
		            	//创建通知单，设置标记为true
		            	MFlag = "true";
					}
				}
                /**
                 * 订单表插入
                 */
                // 订单号
                order.setOrderNO(orderList.get(i).getOrderNO());
                order.setOrderTypeCD(orderList.get(i).getOrderTypeCD());
                // 加急标识CD
                order.setUrgentCD(orderList.get(i).getUrgentCD());
                // 订单日期
                order.setOrderDate(orderList.get(i).getOrderDate());
                // 量体样衣区分
                order.setTryonOrder(orderList.get(i).getTryonOrder());
                // 客户名称（顾客）
                order.setCustomerName(orderList.get(i).getCustomerName());
                // 店铺名
                order.setShopName(orderList.get(i).getShopName());
                // 特殊订单区分
                order.setSpecialOder(orderList.get(i).getSpecialOder());
                // 目的地
                order.setShippingDestintion(orderList.get(i).getShippingDestintion());
                //客户订单号(平台交易号)
                order.setCustomOrderNo(orderList.get(i).getCustomOrderNo());
                //客户
        		order.setCustomName(orderList.get(i).getCustomName());
        		//制作方法
        		order.setMakeShirt(orderList.get(i).getMakeShirt());
        		//Transit Group
        		order.setTransitGroup(orderList.get(i).getTransitGroup());
        		//国家
        		order.setCountryName(orderList.get(i).getCountryName());
                // 船期
                order.setShipmentDate(orderList.get(i).getShipmentDate());
                order.setUserId(userId);
                //订单状态
                order.setOrderStatusCD(ResourcesUtil.getConfig("Paid_20"));
                //生产状态
                order.setOrderProduceStatusCd(ResourcesUtil.getConfig("production_00"));
                //质检状态34
                order.setOrderQuatityStatus34(ResourcesUtil.getConfig("quatity_status_00"));
                //质检状态35
                order.setOrderQuatityStatus35(ResourcesUtil.getConfig("quatity_status_00"));
                //质检状态36
                order.setOrderQuatityStatus36(ResourcesUtil.getConfig("quatity_status_00"));
                //质检状态37
                order.setOrderQuatityStatus37(ResourcesUtil.getConfig("quatity_status_00"));
                // 船期
                order.setSleeveFlag(orderList.get(i).getSleeveFlag());
                // 自带面料区分
                if ("MTM".equals(dataSourceFlag)) {
                	order.setMaterialSource(orderList.get(i).getMaterialSource());
                }
                // 订单备注信息
                order.setRemarks(orderList.get(i).getRemarks());
                // 日本大货和荷兰小样自定义日期
	        	if (ResourcesUtil.getConfig("order_type-type_50").equals(orderType)
	        			|| ResourcesUtil.getConfig("order_type-type_60").equals(orderType)) {
	        		order.setRealDate(orderList.get(i).getRealDate());
	        	}
                /**
                 * 款式表插入
                 */
                // 款式中文名
                bigcargoStyle.setStyleNameCn(styleList.get(i).getStyleNameCn());
                // 款式类别
                bigcargoStyle.setStyleCateGoryCd(styleList.get(i).getStyleCateGoryCd());
                // 尺码组CD
                bigcargoStyle.setSizeGroup(styleList.get(i).getSizeGroup());
                // 尺码
                bigcargoStyle.setStyleSizeGroupCn(styleList.get(i).getStyleSizeGroupCn());
                // 款式制作工艺
                bigcargoStyle.setStyleMakeType(styleList.get(i).getStyleMakeType());
                // 款式版型
                bigcargoStyle.setFitBodyType(styleList.get(i).getFitBodyType());
                // 款式面料编号
                bigcargoStyle.setStyleFabricNo(styleList.get(i).getStyleFabricNo());
                // 款式面料成分
                bigcargoStyle.setStyleComposition(styleList.get(i).getStyleComposition());
                //备注 （小样面料的数量）
                bigcargoStyle.setRemarks(styleList.get(i).getRemarks());
                //定制条形码
                if ("ERP".equals(dataSourceFlag)) {
                	bigcargoStyle.setStyleBarCode(order.getOrderNO().substring(order.getOrderNO().lastIndexOf(".")+1, order.getOrderNO().length()));
				}else if ("MTM".equals(dataSourceFlag)) {
	                bigcargoStyle.setStyleBarCode(order.getOrderNO().substring(order.getOrderNO().lastIndexOf(".")+1,order.getOrderNO().length()));
				}
                String materialId = "0";
				if ("1".equals(order.getMaterialSource())) {
					// 自带面料ID取得
					materialId = orderDao.selectMaterialCustom(styleList.get(i).getStyleFabricNo());
				}else {
					// 库存面料ID取得
                	materialId = orderDao.selectMaterial(styleList.get(i).getStyleFabricNo());
                	
				}
                bigcargoStyle.setCreateUser(String.valueOf(userId));
                if (materialId!= null) {
                    // 款式面料ID
                    bigcargoStyle.setStyleFabricId(materialId);
                } else {
                    // 款式面料ID
                    bigcargoStyle.setStyleFabricId("0");
                }
                // 款式中文名
                bigcargoStyle.setStyleNameCn(styleList.get(i).getStyleNameCn());
                // 款式编号 (内部编号 A-....)
                bigcargoStyle.setStyleNo(styleList.get(i).getStyleNo());
                // 款式设计项目关联表 数据
                bigcargoStyle.setOptionEntityList(styleList.get(i).getOptionEntityList());
                // 品控数据
                bigcargoStyle.setStyleControlList(styleList.get(i).getStyleControlList());
                // 款式设计项目费用关联表 数据
                bigcargoStyle.setCostEntityList(styleList.get(i).getCostEntityList());
                bigcargoStyle.setStyleFit(styleList.get(i).getStyleFit());
                /**
                 * 条形code表插入
                 */
                //款式
                barCode.setQrType("5");
                barCode.setQrBarCode(bigcargoStyle.getStyleBarCode());
                if ("MTM".equals(dataSourceFlag)) {
					// 非春衫店铺订单条码处理
					if (sshirtShopId == orderList.get(i).getShopId()) {
						barCode.setQrName(orderList.get(i).getBusinessNo());
						barCode.setQrOther15(orderList.get(i).getAccountingOrderSize());
					}else {
						barCode.setQrName(orderList.get(i).getOrderNO());
					}
				}else {
					barCode.setQrName(orderList.get(i).getOrderNO());
				}
                barCode.setQrDate(orderList.get(i).getOrderDate());
                barCode.setQrOther2(orderList.get(i).getUrgentCD());
                barCode.setQrOther3(orderList.get(i).getSpecialOder());
                barCode.setQrOther4(styleList.get(i).getStyleFabricNo());
                barCode.setQrOther5(bigcargoStyle.getStyleBarCode());
                barCode.setQrOther9(bigcargoStyle.getStyleBarCode());
                barCode.setQrOther0(customizationContract.getContractNO());
                barCode.setQrOther10(order.getCustomOrderNo());
                barCode.setQrOther11(order.getShopName());
                barCode.setQrOther12(order.getCustomName());
                barCode.setQrOther13(order.getMakeShirt());
                barCode.setQrOther14(orderList.get(i).getStyleBarCode());
                // 春衫店铺订单设置箱号
//                if (sshirtShopId == orderList.get(i).getShopId()) {
//                	barCode.setQrOther14(bigcargoStyle.getStyleBarCode().split("-")[0]);
//                	barCode.setQrOther15(bigcargoStyle.getStyleBarCode());
//				}
                barCode.setQrOther25(order.getShippingDestintion());
                barCode.setQrOther26(orderList.get(i).getAddresseeName());
                barCode.setQrOther27(orderList.get(i).getAddresseeTel());
                barCode.setQrOther28(orderList.get(i).getAddressProvinceCd());
                barCode.setQrOther29(orderList.get(i).getAddressCityCd());
                barCode.setQrOther30(orderList.get(i).getAddressDistrict());
                barCode.setQrOther31(orderList.get(i).getAddressDetail());
                barCode.setQrOther32(orderList.get(i).getZipCode());
                if (styleList.get(i).getStyleComposition() != null) {
                	barCode.setQrOther33(DesignoptionUtils.getDesignoptionNameEn(styleList.get(i).getStyleComposition()));
				}
                barCode.setRemarks(orderList.get(i).getBarInfo());
                barCode.preInsert();
                //扣
                //Sequence sequence=SequenceUtil.ognizationCode(DateUtils.formatDate(new Date(), "yyyyMMdd"), "sequence_orderStyleBarCode", 4);
                barCode2.setQrType("2");
                barCode2.setQrBarCode(bigcargoStyle.getStyleBarCode());
                barCode2.setQrName(orderList.get(i).getOrderNO());
                barCode2.setQrOther1(bigcargoStyle.getStyleBarCode());
                barCode2.setQrOther9(bigcargoStyle.getStyleBarCode());
                String designoptionCN = "";
                List<StyleOptionEntity> styleOptionEntities = styleList.get(i).getOptionEntityList();
                for (int j = 0; j < styleOptionEntities.size(); j++) {
                	designoptionCN = DesignoptionUtils.getDesignoptionName(styleOptionEntities.get(j).getOptionValue());
                	if (designoptionCN!=null&&!"".equals(designoptionCN)) {
                		designoptionCN = "/"+designoptionCN;
					}else {
						designoptionCN = "";
					}
					if ("4SBU".equals(styleOptionEntities.get(j).getItemValue())) {
						barCode2.setQrOther2(styleOptionEntities.get(j).getOptionCost1().split(",")[1]);
						String opCost1 = styleOptionEntities.get(j).getOptionCost1().split(",")[0];
						String scoBtnNum = styleOptionEntities.get(j).getScoBtnNum();
						if ("".equals(opCost1)) {
							opCost1 = "0";
						}
						if ("".equals(scoBtnNum)) {
							scoBtnNum = "0";
						}
						barCode2.setQrOther3((Integer.parseInt(opCost1) - Integer.parseInt(scoBtnNum)) + " ( " + scoBtnNum + " )");
						barCode2.setQrOther4(styleOptionEntities.get(j).getOptionValue()+designoptionCN);
					}else if ("4SAT".equals(styleOptionEntities.get(j).getItemValue())) {
						barCode2.setQrOther5(styleOptionEntities.get(j).getOptionValue()+designoptionCN);
					}else if ("4THN3".equals(styleOptionEntities.get(j).getItemValue())) {
						barCode2.setQrOther6(styleOptionEntities.get(j).getOptionValue()+designoptionCN);
					}else if ("4SCU".equals(styleOptionEntities.get(j).getItemValue())) {
						barCode2.setQrOther8(styleOptionEntities.get(j).getOptionValue()+designoptionCN);
						//手绢
					}else if ("4SPO".equals(styleOptionEntities.get(j).getItemValue())) {
						barCode.setQrOther16(styleOptionEntities.get(j).getOptionValue()+designoptionCN);
						//包装
					}else if ("4SPCK".equals(styleOptionEntities.get(j).getItemValue())) {
						barCode.setQrOther17(styleOptionEntities.get(j).getOptionValue()+designoptionCN);
						//水洗
					}else if ("4WASH".equals(styleOptionEntities.get(j).getItemValue())) {
						barCode.setQrOther18(styleOptionEntities.get(j).getOptionValue()+designoptionCN);
						//吊牌
					}else if ("4HANG".equals(styleOptionEntities.get(j).getItemValue())) {
						String hShirt = styleOptionEntities.get(j).getOptionValue();
						if (hShirt != null) {
							hShirt = hShirt.replace("/", ",").split(",")[0];
						}
						barCode.setQrOther19(hShirt);
						//缎带
					}else if ("4RIBB".equals(styleOptionEntities.get(j).getItemValue())) {
						barCode.setQrOther20(styleOptionEntities.get(j).getOptionValue()+designoptionCN);
					}
				}
                barCode2.setQrOther7(styleList.get(i).getStyleFabricNo());
                barCode2.setQrOther0(customizationContract.getContractNO());
                barCode2.preInsert();
                // 款式表插入
                orderDao.inserStyle(bigcargoStyle);
                order.setStyleId(bigcargoStyle.getStyleID());
                // 订单表插入
                orderDao.inserOder(order);
                // 定制合同详情表插入
                if ("ERP".equals(dataSourceFlag)) {
                	orderDao.insertContractDetail(customizationContract.getId(),order.getId(),0);
				}else if ("MTM".equals(dataSourceFlag)) {
					orderDao.insertContractDetail(customizationContract.getId(),order.getId(),3);
				}
                // 款式关联表插入
                orderDao.inserOderAndStyle(order.getId(),bigcargoStyle.getStyleID());
                // 款式设计项目关联表插入
                orderDao.insertOpintion(bigcargoStyle);
                // 品控插入
                orderDao.insertStyleControl(bigcargoStyle);
//                Integer partNum = orderDao.selectSum(bigcargoStyle.getStyleID());
//                if (partNum == null) {
//                	partNum = 0;
//				}
                barCode.setQrOther6("24");
                // 条形表插入
                orderDao.inserBarCode(barCode);
                orderDao.inserBarCodeSBU(barCode2);
                if(styleList.get(i).getCostEntityList().size()>0){
                    // 款式设计项目费用关联表插入
                    orderDao.insertStyleCost(bigcargoStyle);
                }
                // 款式量体项目关联表插入
                orderDao.insertFitStyle(bigcargoStyle);
                //插入生产通知单和订单关联表
                //机缝订单
                if ("M".equals(makeType)) {
                	produceNotice_M.setIndentID(order.getId());
                	produceNoticeDao.insertNoticeOrder(produceNotice_M);
                //手缝订单
				}else if ("H".equals(makeType)) {
					produceNotice_H.setIndentID(order.getId());
					produceNoticeDao.insertNoticeOrder(produceNotice_H);
				//非荷兰定制订单
				}else {
					produceNotice.setIndentID(order.getId());
					produceNoticeDao.insertNoticeOrder(produceNotice);
				}
                count++;
                if (!ResourcesUtil.getConfig("order_type-type_50").equals(orderType)
                		&& !ResourcesUtil.getConfig("order_type-type_60").equals(orderType)) {
	                /**
	                 * 工序初始数据
	                 */
	                //订单号
	                operatingEntity.setOrderNo(orderList.get(i).getOrderNO());
	                //订单ID
	                operatingEntity.setOrderId(order.getId());
	                //订单类型CD
	                operatingEntity.setOrderTypeNo(orderList.get(i).getOrderTypeCD());
	                //款式ID
	                operatingEntity.setStyleId(bigcargoStyle.getStyleID());
	                //生产号
	                operatingEntity.setStyleNo("");
	                //款式类型CDrordeor
	                operatingEntity.setStyleKbn(styleList.get(i).getStyleCateGoryCd());
	                //条形码
	                operatingEntity.setStyleBarCode(bigcargoStyle.getStyleBarCode());
	                //合同ID
	                operatingEntity.setContractID(customizationContract.getId());
	                //工序状态
	                operatingEntity.setOperatingStatus(ResourcesUtil.getConfig("OPERATING_STATUS00"));
	                //面料号
	                operatingEntity.setMaterialCode(styleList.get(i).getStyleFabricNo());
	                for(OperatingEntity oEntity :operatingIdList){
	                	StyleOperationtings tempEntity = operatingEntity.clone();
	                	tempEntity.preInsert();
	                	//工序ID
	                	tempEntity.setOperationItmeId(oEntity.getOperatingId());
	                	operatingDataList.add(tempEntity);
	                }
	                //插入工序数据集
	                orderDao.insertOperatingList(operatingDataList);
	                operatingDataList = new ArrayList<>();
                }
                System.out.println("基础数据 "+i+" 完成--"+new Date());
            }
            //非荷兰定制订单更新生产计划和生产通知单 订单数量
            if (!"ORDER_TYPE-TYPE_10".equals(orderType)) {
            	//更新订单数量
            	producePlan.preUpdate();
				producePlan.setPlanQuantity(new BigDecimal(count));
				producePlanDao.updateOrderQuantity(producePlan);
				produceNotice.preUpdate();
				produceNotice.setNoticeQuantity(new BigDecimal(count));
				produceNoticeDao.updateOrderQuantity(produceNotice);
            //荷兰定制订单
            }else {
				//更新机缝订单数量
				producePlan_M.preUpdate();
				producePlan_M.setPlanNO("P." + venderSimpleName + ".M." + styleNo4M);
				producePlan_M.setPlanQuantity(new BigDecimal(MQuantity));
				producePlanDao.updateOrderQuantity(producePlan_M);
				produceNotice_M.preUpdate();
				produceNotice_M.setNoticeQuantity(new BigDecimal(MQuantity));
				produceNoticeDao.updateOrderQuantity(produceNotice_M);
				//更新手缝订单数量
				producePlan_H.setPlanNO("P." + venderSimpleName + ".H." + styleNo4H);
				producePlan_H.setPlanQuantity(new BigDecimal(HQuantity));
				producePlanDao.updateOrderQuantity(producePlan_H);
				produceNotice_H.preUpdate();
				produceNotice_H.setNoticeQuantity(new BigDecimal(HQuantity));
				produceNoticeDao.updateOrderQuantity(produceNotice_H);
			}
        }
        System.out.println("基本数据完成------"+new Date());
		insertTempTable (orderType);
        System.out.println("temp表数据完成------"+new Date());
        insertStyleNo (venderSimpleName,orderType);
        System.out.println("更新生产号完成------"+new Date());
	    if (!ResourcesUtil.getConfig("order_type-type_50").equals(orderType)
	    		&& !ResourcesUtil.getConfig("order_type-type_60").equals(orderType)) {
	        updateAllOperatingData(customizationContract.getId());
	        System.out.println("工序数据更新完成------"+new Date());
        }
        System.out.println("定制导入结束-------------"+new Date());
        return customizationContract.getId();
    }
    
    /**
     * 更新所有工序表数据
     * @param contractId
     * @throws Exception
     */
    public void updateAllOperatingData(Long contractId) throws Exception{
        // 工序ID集
        List<OperatingEntity> operatingIdList = findOperatingIdList();
        Order order = new Order();
        order.setContractID(contractId+"");
        //获取工序下量体code
        List<Order> fitList = findFitCodeList (order);
        //通过合同ID获取订单集
        List<Order> orderList = findOrderList(order);
        System.out.println("工序数据处理开始----"+new Date());
    	for(OperatingEntity oEntity :operatingIdList){
    		updateOperatingData(order,oEntity,fitList,orderList);
        }
    	System.out.println("工序数据处理结束----"+new Date());
    }
    
    /**
     * 更新一道工序工序表数据
     * @param order
     * @param operatingEntity
     * @param fitList
     * @param orderList
     * @throws Exception
     */
    public void updateOperatingData(Order order,OperatingEntity operatingEntity,List<Order> fitList,List<Order> orderList) throws Exception{
    	// 工序数据集
        List<StyleOperationtings> operatingDataList = new ArrayList<>();
    	order.setOperatingId(operatingEntity.getOperatingId());
    	//获取订单工序数据集
    	List<Order> optinList = findOptionValueList (order);
		operatingDataList = makeOperatingList(operatingEntity, optinList, fitList, orderList);
		System.out.println("合同 "+order.getContractID()+" 工序 "+operatingEntity.getOperatingId()+" 处理完成--"+new Date());
		if (operatingDataList != null && operatingDataList.size() > 0) {
			//更新工序数据
			orderDao.updateOperatingList(operatingDataList);
		}
		System.out.println("合同 "+order.getContractID()+" 工序"+operatingEntity.getOperatingId()+" 数据更新完成----"+new Date());
    }
    
    /**
     * MTM平台数据处理
     * @param str
     * @return
     */
    public String nulReturnStr(String str){
    	if (str != null) {
    		if ("no".equals(str)) {
    			return "";
			}
			return str;
		}
    	return "";
    }
    
    /**
     * MTM平台数据插入
     * @param cloudList
     * @return
     * @throws Exception
     */
    public void insertExcelDataBeforeMTM (List<OrderSyncJobCache> cloudList) throws Exception{
    	StyleDesignHistoryEntity cloudEntity = new StyleDesignHistoryEntity();
    	List<StyleDesignHistoryEntity> styleDesignList = new ArrayList<>();
    	Date targetDate = null;
    	//订单
		OrderEntity orderEntity = new OrderEntity();
		//款式
		StyleEntity styleEntity = new StyleEntity();
		//款式量体
		StyleFitEntity styleFitEntity = new StyleFitEntity();
		//设计费用
		StyleCostEntity styleCostEntity = new StyleCostEntity();
		//款式项目集
	    List<StyleOptionREntity> styleOptionList;
    	List<OrderSyncJobCache> oList = new ArrayList<>();
    	if (cloudList != null && cloudList.size() > 0) {
			for (int i = 0; i < cloudList.size(); i++) {
				if (cloudList.get(i) != null) {
					oList = cloudList.get(i).getCloudList();
					if (oList != null && oList.size() > 0) {
						for (int j = 0; j < oList.size(); j++) {
							if (oList.get(j) != null) {
								//订单
								orderEntity = oList.get(j).getOrderEntity();
								if (orderEntity != null) {
									// 店铺id
									cloudEntity.setShopId(String.valueOf(orderEntity.getShopId()));
									//订单号
									cloudEntity.setOrderNo(nulReturnStr(orderEntity.getOrderNo()));
									//订单日期
									cloudEntity.setOrderDate(orderEntity.getOrderDate());
									//客户名称
									cloudEntity.setCustomerName(nulReturnStr(orderEntity.getCustomerName()));
									//店名
									cloudEntity.setShopName(nulReturnStr(orderEntity.getShopName()));
									//客户订单号(平台交易号)
									cloudEntity.setCustomOrderNo(nulReturnStr(orderEntity.getOrderNo()));
									//客户（顾客）
									cloudEntity.setCustomName(nulReturnStr(orderEntity.getCustomName()));
									//制作方法
									cloudEntity.setCustomMakeShirt(nulReturnStr(orderEntity.getCustomMakeShirt()));
									//Transit Group
									cloudEntity.setTransitGroup(nulReturnStr(orderEntity.getTransitGroup()));
									//国家
									cloudEntity.setCountry(nulReturnStr(orderEntity.getCountry()));
									//船期
									cloudEntity.setShipmentDate(orderEntity.getTargetDate());
									//设置合同交货日期
									if (targetDate == null) {
										targetDate = orderEntity.getTargetDate();
									}
									//交期重要
									cloudEntity.setUrgentOrder(nulReturnStr(orderEntity.getUrgentCd()));
									//量体样衣
									cloudEntity.setTryonOrder(nulReturnStr(orderEntity.getTryonOrder()));
									//特殊订单
									cloudEntity.setSpecialOrder(nulReturnStr(orderEntity.getSpecialOrder()));
									//发货目的地
									cloudEntity.setShippingDestination(nulReturnStr(orderEntity.getShippingDestination()));
									//自带面料区分
									cloudEntity.setMaterialSource(orderEntity.getMaterialSource());
									//平台订单备注信息
									cloudEntity.setRemarks(orderEntity.getRemarks());
								}	
								//款式
								styleEntity = oList.get(j).getStyleEntity();
								if (styleEntity != null) {
									//款式类别
									cloudEntity.setOrderParts(nulReturnStr(styleEntity.getStyleCategoryCd()));
									//面料品号 (云云)
									cloudEntity.setFabricCode(nulReturnStr(styleEntity.getSytleFabricNo()).split("/")[0].trim()); 
									//面料成分 (云云)
									if (nulReturnStr(styleEntity.getStyleComposition()).split("-").length > 1) {
										cloudEntity.setFabricComposition(nulReturnStr(styleEntity.getStyleComposition()).split("-")[1]);
									}else {
										cloudEntity.setFabricComposition(nulReturnStr(styleEntity.getStyleComposition()));
									}
									//款式中文名（新版）
									if (styleEntity.getStyleNameCn() != null && !"".equals(styleEntity.getStyleNameCn())) {
										cloudEntity.setStyleNameCn("NEW SHIRT:"+styleEntity.getStyleNameCn());
									}else {
										cloudEntity.setStyleNameCn("NEW SHIRT:新版衬衫");
									}
									//款式制作工艺
									cloudEntity.setModelSma(styleEntity.getStyleMakeType().split("-")[1]);
									//款式版型
									cloudEntity.setModelShm(styleEntity.getStyleFitCd().split("-")[1]);
									//衬衫规格
									cloudEntity.setShirtSize(styleEntity.getStyleSizeCd().split("-")[1]);
									//尺码组code
									cloudEntity.setSizeGroup(nulReturnStr(styleEntity.getStyleSizeGroupCd()));
									//尺码code
									cloudEntity.setSizeCd(nulReturnStr(styleEntity.getStyleSizeCd()));
									//原辅料费用
									cloudEntity.setMaterialCost(nulReturnStr(styleEntity.getStyleMaterialNumber()+""));
									// 交易号（小程序订单）
									cloudEntity.setBusinessNo(nulReturnStr(oList.get(j).getBusinessNo()));
									// 交易条码（小程序订单）
									cloudEntity.setBusinessBarCode(nulReturnStr(styleEntity.getStyleBarCode()));
									// 交易订单数量（小程序订单）
									cloudEntity.setAccountingOrderSize(nulReturnStr(oList.get(j).getAccountingOrderSize()));
									// 设置收货地址信息
									cloudEntity.setAddresseeName(oList.get(j).getAddresseeName());
									cloudEntity.setAddresseeTel(oList.get(j).getAddresseeTel());
									cloudEntity.setAddressProvinceCd(oList.get(j).getAddressProvinceCd());
									cloudEntity.setAddressCityCd(oList.get(j).getAddressCityCd());
									cloudEntity.setAddressDistrict(oList.get(j).getAddressDistrict());
									cloudEntity.setAddressDetail(oList.get(j).getAddressDetail());
									cloudEntity.setZipCode(oList.get(j).getZipCode());
								}
								//款式量体
								styleFitEntity = oList.get(j).getStyleFitEntity();
								if (styleFitEntity != null) {
									//平台量尺itemValue字符集
									cloudEntity.setItemValueMTM(styleFitEntity.getItemValue());
									//量尺加值
									cloudEntity.setInValue(styleFitEntity.getInValue());
									//量尺减值
									cloudEntity.setOutValue(styleFitEntity.getOutValue());
									/*------------云------------*/
									//胸围
									cloudEntity.setSize12che("0");
									//腰围
									cloudEntity.setSize12wai("0");
									//底摆
									cloudEntity.setSize12hip("0");
									//肩宽
									cloudEntity.setSizeYok("0");
									//后衣长
									cloudEntity.setSizeLen("0");
									//领围
									cloudEntity.setSizeCol("0");
									//大臂围
									cloudEntity.setSizeUam("0");
									//左小臂围
									cloudEntity.setSizeFal("0");
									//右小臂围
									cloudEntity.setSizeFar("0");
									//左袖头围缩小
									cloudEntity.setSizeScl("0");
									//右袖头围缩小
									cloudEntity.setSizeScr("0");
									//左袖头围左
									cloudEntity.setSizeCll("0");
									//右袖头围右
									cloudEntity.setSizeClr("0");
									//左袖短
									cloudEntity.setSizeSsl("0");
									//右袖短
									cloudEntity.setSizeSsr("0");
									//左袖长左
									cloudEntity.setSizeSll("0");
									//右袖长右
									cloudEntity.setSizeSlr("0");
									//左肩底
									cloudEntity.setSizeLsl("0");
									//右肩底
									cloudEntity.setSizeLsr("0");
									//前立扣位
									cloudEntity.setSizeRbh("0");
									//前立扣数
									cloudEntity.setSizeBof("0");
									/*-----------云-----------*/
									String[] valueList = styleFitEntity.getItemValue().split(",");
									String[] fitValueList = styleFitEntity.getFitValue().split(",");
									String[] fmValueList = styleFitEntity.getFmValue().split(",");
									String[] inValueList = styleFitEntity.getInValue().split(",");
									String[] outValueList = styleFitEntity.getOutValue().split(",");
									//量体加减值数据
									if (valueList != null && valueList.length>0) {
										for (int k = 0; k < valueList.length; k++) {
											//10.左袖头围缩小
											if (ResourcesUtil.getConfig("CIRCUITEM15").equals(valueList[k])) {
												if ("NaN".equals(inValueList[k]) && !"NaN".equals(outValueList[k])) {
													cloudEntity.setSizeScl(outValueList[k]);
												}else if (!"NaN".equals(inValueList[k]) && "NaN".equals(outValueList[k])) {
													cloudEntity.setSizeScl(inValueList[k]);
												}
											}
											//11.右袖头围缩小
											else if (ResourcesUtil.getConfig("CIRCUITEM16").equals(valueList[k])) {
												if ("NaN".equals(inValueList[k]) && !"NaN".equals(outValueList[k])) {
													cloudEntity.setSizeScr(outValueList[k]);
												}else if (!"NaN".equals(inValueList[k]) && "NaN".equals(outValueList[k])) {
													cloudEntity.setSizeScr(inValueList[k]);
												}
											}
											//14.左袖短
											else if (ResourcesUtil.getConfig("CIRCUITEM20").equals(valueList[k])) {
												if ("NaN".equals(inValueList[k]) && !"NaN".equals(outValueList[k])) {
													cloudEntity.setSizeSsl(outValueList[k]);
												}else if (!"NaN".equals(inValueList[k]) && "NaN".equals(outValueList[k])) {
													cloudEntity.setSizeSsl(inValueList[k]);
												}
											}
											//15.右袖短
											else if (ResourcesUtil.getConfig("CIRCUITEM22").equals(valueList[k])) {
												if ("NaN".equals(inValueList[k]) && !"NaN".equals(outValueList[k])) {
													cloudEntity.setSizeSsr(outValueList[k]);
												}else if (!"NaN".equals(inValueList[k]) && "NaN".equals(outValueList[k])) {
													cloudEntity.setSizeSsr(inValueList[k]);
												}
											}
											//18.左肩底
											else if (ResourcesUtil.getConfig("CIRCUITEM19").equals(valueList[k])) {
												if ("NaN".equals(inValueList[k]) && !"NaN".equals(outValueList[k])) {
													cloudEntity.setSizeLsl(outValueList[k]);
												}else if (!"NaN".equals(inValueList[k]) && "NaN".equals(outValueList[k])) {
													cloudEntity.setSizeLsl(inValueList[k]);
												}
											}
											//19.右肩底
											else if (ResourcesUtil.getConfig("CIRCUITEM21").equals(valueList[k])) {
												if ("NaN".equals(inValueList[k]) && !"NaN".equals(outValueList[k])) {
													cloudEntity.setSizeLsr(outValueList[k]);
												}else if (!"NaN".equals(inValueList[k]) && "NaN".equals(outValueList[k])) {
													cloudEntity.setSizeLsr(inValueList[k]);
												}
											}
										}
									}
									//量体常规数据
									if (fmValueList != null && fmValueList.length>0) {
										for (int k = 0; k < fmValueList.length; k++) {
											//1.胸围
											if (ResourcesUtil.getConfig("CIRCUITEM02").equals(fmValueList[k])) {
												cloudEntity.setSize12che(fitValueList[k]);
											}
											//2.腰围
											else if (ResourcesUtil.getConfig("CIRCUITEM05").equals(fmValueList[k])) {
												cloudEntity.setSize12wai(fitValueList[k]);
											}
											//3.底摆
											else if (ResourcesUtil.getConfig("CIRCUITEM06").equals(fmValueList[k])) {
												cloudEntity.setSize12hip(fitValueList[k]);
											}
											//4.肩宽
											else if (ResourcesUtil.getConfig("CIRCUITEM07").equals(fmValueList[k])) {
												cloudEntity.setSizeYok(fitValueList[k]);
											}
											//云.前身长
											else if (ResourcesUtil.getConfig("LENGTITEM01").equals(fmValueList[k])) {
												cloudEntity.setSizeYunLen(fitValueList[k]);
											}
											//5.后衣长
											else if (ResourcesUtil.getConfig("LENGTITEM02").equals(fmValueList[k])) {
												cloudEntity.setSizeLen(fitValueList[k]);
											}
											//6.领围
											else if (ResourcesUtil.getConfig("CIRCUITEM01").equals(fmValueList[k])) {
												cloudEntity.setSizeCol(fitValueList[k]);
											}
											//7.大臂围
											else if (ResourcesUtil.getConfig("LENGTITEM08").equals(fmValueList[k])) {
												cloudEntity.setSizeUam(fitValueList[k]);
											}
											//8.左小臂围
											else if (ResourcesUtil.getConfig("LENGTITEM09").equals(fmValueList[k])) {
												cloudEntity.setSizeFal(fitValueList[k]);
											}
											//9.右小臂围
											else if (ResourcesUtil.getConfig("LENGTITEM10").equals(fmValueList[k])) {
												cloudEntity.setSizeFar(fitValueList[k]);
											}
											//12.左袖头围左
											else if (ResourcesUtil.getConfig("CIRCUITEM17").equals(fmValueList[k])) {
												cloudEntity.setSizeCll(fitValueList[k]);
											}
											//13.右袖头围右
											else if (ResourcesUtil.getConfig("CIRCUITEM18").equals(fmValueList[k])) {
												cloudEntity.setSizeClr(fitValueList[k]);
											}
											
											//16.左袖长左
											else if (ResourcesUtil.getConfig("POSTUITEM07").equals(fmValueList[k])) {
												cloudEntity.setSizeSll(fitValueList[k]);
											}
											//17.右袖长右
											else if (ResourcesUtil.getConfig("POSTUITEM09").equals(fmValueList[k])) {
												cloudEntity.setSizeSlr(fitValueList[k]);
											}
											//20.前立扣位
											else if (ResourcesUtil.getConfig("POSTUITEM06").equals(fmValueList[k])) {
												cloudEntity.setSizeRbh(fitValueList[k]);
											}
											//21.前立扣数
											else if (ResourcesUtil.getConfig("POSTUITEM08").equals(fmValueList[k])) {
												cloudEntity.setSizeBof(fitValueList[k]);
											}
										}
									}
								}
								//款式项目集
								styleOptionList = oList.get(j).getStyleOptionList();
								if (styleOptionList != null && styleOptionList.size() > 0) {
									StyleOptionREntity cloud = null;
									for (int k = 0; k < styleOptionList.size(); k++) {
										cloud = styleOptionList.get(k);
										if (cloud != null) {
											//袖子
											if ("4SSL".equals(cloud.getItemValue())) {
												cloudEntity.setModelSsl(nulReturnStr(cloud.getOptionValue()));
											}
											//领子
											else if ("4SCO".equals(cloud.getItemValue())) {
												cloudEntity.setModelSco(nulReturnStr(cloud.getOptionValue()));
											}
											//袖头
											else if ("4SCU".equals(cloud.getItemValue())) {
												cloudEntity.setModelScu(nulReturnStr(cloud.getOptionValue()));
											}
											//袖开祺
											else if ("4SSV".equals(cloud.getItemValue())) {
												cloudEntity.setModelSsv(nulReturnStr(cloud.getOptionValue()));
											}
											//衬布
											else if ("4SSK".equals(cloud.getItemValue())) {
												cloudEntity.setModelSsk(nulReturnStr(cloud.getOptionValue()));
											}
											//领插签
											else if ("4SBO".equals(cloud.getItemValue())) {
												cloudEntity.setModelSbo(nulReturnStr(cloud.getOptionValue()));
											}
											//前立
											else if ("4SFP".equals(cloud.getItemValue())) {
												cloudEntity.setModelSfp(nulReturnStr(cloud.getOptionValue()));
											}
											//胸兜
											else if ("4SBP".equals(cloud.getItemValue())) {
												cloudEntity.setModelSbp(nulReturnStr(cloud.getOptionValue()));
											}
											//后背款式
											else if ("4SBA".equals(cloud.getItemValue())) {
												cloudEntity.setModelSba(nulReturnStr(cloud.getOptionValue()));
											}
											//领子,袖口明线
											else if ("4SST".equals(cloud.getItemValue())) {
												cloudEntity.setModelSst  (nulReturnStr(cloud.getOptionValue()));
											}
											//手绢
											else if ("4SPO".equals(cloud.getItemValue())) {
												cloudEntity.setModelSpo(nulReturnStr(cloud.getOptionValue()));
											}
											//后省
											else if ("4SBD".equals(cloud.getItemValue())) {
												cloudEntity.setModelSbd(nulReturnStr(cloud.getOptionValue()));
											}
											//过肩
											else if ("4SBJ".equals(cloud.getItemValue())) {
												cloudEntity.setModelSbj(nulReturnStr(cloud.getOptionValue()));
											}
											//底摆款式
											else if ("4SBS".equals(cloud.getItemValue())) {
												cloudEntity.setModelSbs(nulReturnStr(cloud.getOptionValue()));
											}
											//缝制线
											else if ("4THN1".equals(cloud.getItemValue())) {
												cloudEntity.setTrimThdno(nulReturnStr(cloud.getOptionValue()));
											}
											//线号
											else if ("4SGD".equals(cloud.getItemValue())) {
												cloudEntity.setTrimSgd(nulReturnStr(cloud.getOptionValue()));
											}
											//扣
											else if ("4SBU".equals(cloud.getItemValue())) {
												cloudEntity.setTrimSbu(nulReturnStr(cloud.getOptionValue()));
											}
											//扣眼颜色
											else if ("4THN2".equals(cloud.getItemValue())) {
												cloudEntity.setTrimSbh(nulReturnStr(cloud.getOptionValue()));
											}
											//订扣
											else if ("4SAT".equals(cloud.getItemValue())) {
												cloudEntity.setTrimSat(nulReturnStr(cloud.getOptionValue()));
											}
											//钉扣线颜色
											else if ("4THN3".equals(cloud.getItemValue())) {
												cloudEntity.setTrimSbt(nulReturnStr(cloud.getOptionValue()));
											}
											//领子,袖头配色线
											else if ("4THN4".equals(cloud.getItemValue())) {
												cloudEntity.setTrimSts(nulReturnStr(cloud.getOptionValue()));
											}
											//台领下夹牙绳
											else if ("4SBI".equals(cloud.getItemValue())) {
												cloudEntity.setTrimSbi(nulReturnStr(cloud.getOptionValue()));
											}
											//水洗要求
											else if ("4WASH".equals(cloud.getItemValue())) {
												cloudEntity.setModelWash(nulReturnStr(cloud.getOptionValue()));
											}
											//包装方法
											else if ("4SPCK".equals(cloud.getItemValue())) {
												cloudEntity.setModelSpck(nulReturnStr(cloud.getOptionValue()));
											}
											//缎带
											else if ("4RIBB".equals(cloud.getItemValue())) {
												cloudEntity.setModelRibb(nulReturnStr(cloud.getOptionValue()));
											}
											//小号
											else if ("4SIZELB".equals(cloud.getItemValue())) {
												cloudEntity.setLablSize(nulReturnStr(cloud.getOptionValue()));
											}
											//标牌_位置1：后领中订商标
											else if ("LP01".equals(cloud.getItemValue())) {
												cloudEntity.setLablLp1(nulReturnStr(cloud.getOptionValue()));
											}
											//标牌_位置2：三角巾
											else if ("LP02".equals(cloud.getItemValue())) {
												cloudEntity.setLablLp2(nulReturnStr(cloud.getOptionValue()));
											}
											//标牌_位置3：上前立里侧订商标
											else if ("LP03".equals(cloud.getItemValue())) {
												cloudEntity.setLablLp3(nulReturnStr(cloud.getOptionValue()));
											}
											//标牌_位置4：下前立里侧订商标
											else if ("LP04".equals(cloud.getItemValue())) {
												cloudEntity.setLablLp4(nulReturnStr(cloud.getOptionValue()));
											}
											//标牌_位置5：大布订商标
											else if ("LP05".equals(cloud.getItemValue())) {
												cloudEntity.setLablLp5(nulReturnStr(cloud.getOptionValue()));
											}
											//标牌_位置6：后领缝商标
											else if ("LP06".equals(cloud.getItemValue())) {
												cloudEntity.setLablLp6(nulReturnStr(cloud.getOptionValue()));
											}
											//吊牌
											else if ("4HANG".equals(cloud.getItemValue())) {
												cloudEntity.setLablHas(nulReturnStr(cloud.getOptionValue()));
											}
											//洗涤成分
											else if ("4CALB".equals(cloud.getItemValue())) {
												cloudEntity.setLablCl(nulReturnStr(cloud.getOptionValue()));
											}
											//Care label type
											else if ("4CALBT".equals(cloud.getItemValue())) {
												cloudEntity.setLablClt(nulReturnStr(cloud.getOptionValue()));
											}
											//产地标
											else if ("4COFO".equals(cloud.getItemValue())) {
												if ("".equals(cloud.getOptionValue()) || cloud.getOptionValue() == null) {
													cloudEntity.setLablCoo("-/无产地标");
												}else {
													cloudEntity.setLablCoo(nulReturnStr(cloud.getOptionValue()));
												}
											}
											//台领里配料
											else if ("SC1".equals(cloud.getItemValue())) {
												cloudEntity.setContSc1(nulReturnStr(cloud.getOptionValue()));
											}
											//羽领，台领配料
											else if ("SC2".equals(cloud.getItemValue())) {
												cloudEntity.setContSc2(nulReturnStr(cloud.getOptionValue()));
											}
											//袖头里配料
											else if ("SC3".equals(cloud.getItemValue())) {
												cloudEntity.setContSc3(nulReturnStr(cloud.getOptionValue()));
											}
											//袖头配料
											else if ("SC4".equals(cloud.getItemValue())) {
												cloudEntity.setContSc4(nulReturnStr(cloud.getOptionValue()));
											}
											//台领配料
											else if ("SC5".equals(cloud.getItemValue())) {
												cloudEntity.setContSc5(nulReturnStr(cloud.getOptionValue()));
											}
											//上前立表配料
											else if ("SC6".equals(cloud.getItemValue())) {
												cloudEntity.setContSc6(nulReturnStr(cloud.getOptionValue()));
											}
											//下前立配料
											else if ("SC7".equals(cloud.getItemValue())) {
												cloudEntity.setContSc7(nulReturnStr(cloud.getOptionValue()));
											}
											//袖补强布配料
											else if ("SC8".equals(cloud.getItemValue())) {
												cloudEntity.setContSc8(nulReturnStr(cloud.getOptionValue()));
											}
											//手绢配料
											else if ("SC9".equals(cloud.getItemValue())) {
												cloudEntity.setContSc9(nulReturnStr(cloud.getOptionValue()));
											}
											//大布配料
											else if ("SC0".equals(cloud.getItemValue())) {
												cloudEntity.setContSc0(nulReturnStr(cloud.getOptionValue()));
											}
											/******************J.Press*******************/
											//台领、羽领配料
											else if ("JP_A".equals(cloud.getItemValue())) {
												cloudEntity.setContJpA(nulReturnStr(cloud.getOptionValue()));
											}
											//上前身（左）+左面三角布
											else if ("JP_HSB".equals(cloud.getItemValue())) {
												cloudEntity.setContJpHSB(nulReturnStr(cloud.getOptionValue()));
											}
											//下前身（右）+右面三角布
											else if ("JP_HSC".equals(cloud.getItemValue())) {
												cloudEntity.setContJpHSC(nulReturnStr(cloud.getOptionValue()));
											}
											//左袖+左大小布
											else if ("JP_HSD".equals(cloud.getItemValue())) {
												cloudEntity.setContJpHSD(nulReturnStr(cloud.getOptionValue()));
											}
											//右袖+右大小布
											else if ("JP_HSE".equals(cloud.getItemValue())) {
												cloudEntity.setContJpHSE(nulReturnStr(cloud.getOptionValue()));
											}
											//左袖头
											else if ("JP_HSF".equals(cloud.getItemValue())) {
												cloudEntity.setContJpHSF(nulReturnStr(cloud.getOptionValue()));
											}
											//右袖头
											else if ("JP_HSG".equals(cloud.getItemValue())) {
												cloudEntity.setContJpHSG(nulReturnStr(cloud.getOptionValue()));
											}
											//兜
											else if ("JP_H1".equals(cloud.getItemValue())) {
												cloudEntity.setContJpH1(nulReturnStr(cloud.getOptionValue()));
											}
											//育克（表里）
											else if ("JP_I".equals(cloud.getItemValue())) {
												cloudEntity.setContJpI(nulReturnStr(cloud.getOptionValue()));
											}
											//后片+小鼻
											else if ("JP_J".equals(cloud.getItemValue())) {
												cloudEntity.setContJpJ(nulReturnStr(cloud.getOptionValue()));
											}
											//前片+两侧三角布
											else if ("JP_B".equals(cloud.getItemValue())) {
												cloudEntity.setContJpB(nulReturnStr(cloud.getOptionValue()));
											}
											//左袖
											else if ("JP_D".equals(cloud.getItemValue())) {
												cloudEntity.setContJpD(nulReturnStr(cloud.getOptionValue()));
											}
											//右袖
											else if ("JP_E".equals(cloud.getItemValue())) {
												cloudEntity.setContJpE(nulReturnStr(cloud.getOptionValue()));
											}
											/******************J.Press*******************/
											//刺绣内容
											else if ("4SMT".equals(cloud.getItemValue())) {
												cloudEntity.setEmbrText(nulReturnStr(cloud.getOptionValue()).replace(",", "&#44"));
											}
											//刺绣颜色
											else if ("4SMC".equals(cloud.getItemValue())) {
												cloudEntity.setEmbrSmc(nulReturnStr(cloud.getOptionValue()));
											}
											//字体
											else if ("4SMO".equals(cloud.getItemValue())) {
												cloudEntity.setEmbrSmo(nulReturnStr(cloud.getOptionValue()));
											}
											//刺绣位置
											else if ("4SMP".equals(cloud.getItemValue())) {
												cloudEntity.setEmbrSmp(nulReturnStr(cloud.getOptionValue()));
											}
											//刺绣尺寸
											else if ("4SMS".equals(cloud.getItemValue())) {
												cloudEntity.setEmbrSms(nulReturnStr(cloud.getOptionValue()));
											}
											//物料针码
											else if ("STITCH".equals(cloud.getItemValue())) {
												cloudEntity.setModelStitch(nulReturnStr(cloud.getOptionValue()));
											}
											//面料标
											else if ("FABRIC".equals(cloud.getItemValue())) {
												cloudEntity.setLablFabric(nulReturnStr(cloud.getOptionValue()));
											}
										}
									}
								}
								//款式项目费用
								styleCostEntity = oList.get(j).getStyleCostEntity();
								if (styleCostEntity != null) {
									cloudEntity.setDesignCostCode(styleCostEntity.getCostItem2());
									cloudEntity.setDesignCostValue(styleCostEntity.getCostItem4());
									cloudEntity.setDesignCostCost(styleCostEntity.getCostItem5());
								}
								//判断袖子，1为短袖，0为长袖
			                    if (("".equals(cloudEntity.getModelScu())||"-".equals(cloudEntity.getModelScu())||"--".equals(cloudEntity.getModelScu()))&&("".equals(cloudEntity.getModelSsv())||"-".equals(cloudEntity.getModelSsv())||"--".equals(cloudEntity.getModelSsv()))) {
				                    cloudEntity.setSleeveFlag(1);
								}else {
				                    cloudEntity.setSleeveFlag(0);
								}
			                    /////////
			                    String barInfo = "";
			                    barInfo = barInfo + "款式名称：" + String.valueOf(styleEntity.getStyleNameCn()) + "|";
			                    barInfo = barInfo + "性别：" + (("1".equals(orderEntity.getSex())) ? "女衫" : "男衫") + "|";
			                    barInfo = barInfo + "面料号：" + String.valueOf(cloudEntity.getFabricCode()) + "|";
			                    barInfo = barInfo + "扣号：" + String.valueOf(cloudEntity.getTrimSbu());
			                    /////////
			                    cloudEntity.setBarInfo(barInfo);
								styleDesignList.add(cloudEntity);
								cloudEntity = new StyleDesignHistoryEntity();
							}
						}
						Long contractId = insertExcelDataBefore (styleDesignList,cloudList.get(i).getOgnizationShortName(),cloudList.get(i).getOgnizationId(),"","MTM",targetDate,null);
						styleDesignList = new ArrayList<>();
						//导入成功给指定人员发送邮件
			            CustomizationContract contract = getContractInfo(contractId);
			            String url =  ResourcesUtil.getConfig("address")+"/customization/order/order?contractID="
				        	+ contract.getId() + "&contractNo=" + contract.getContractNO() + "&imageFlag=customizationContract&contractDate=" + DateUtils.formatDate(contract.getCreateDate(), "yyyy-MM-dd");
			            SendEmailMessage sendEmailMessage = new SendEmailMessage();
			            sendEmailMessage.setDataTheme(ResourcesUtil.getConfig("erp_send_mail_theme02"));
			            sendEmailMessage.setDataMessage(ResourcesUtil.getConfig("erp_send_mail_textMessage02"));
			            sendEmailMessage.setDataXXX02(contract.getContractNO());
			            sendEmailMessage.setDataXXX03(contract.getOrderQuantity());
			            sendEmailMessage.setDataXURLX(url);
			            sendEmailMessage.setDataYYMMDD01(DateUtils.formatDate(contract.getCreateDate(), "yyyy-MM-dd").toString());
			            String dateStr = "";
			            if (contract.getContractDeliveryHDate() != null) {
			            	dateStr = DateUtils.formatDate(contract.getContractDeliveryDate(), "yyyy-MM-dd") + " / " + DateUtils.formatDate(contract.getContractDeliveryHDate(), "yyyy-MM-dd");
						}else {
							dateStr = DateUtils.formatDate(contract.getContractDeliveryDate(), "yyyy-MM-dd");
						}
			            sendEmailMessage.setDataYYMMDD02(dateStr);
			            //发送邮件
			            UserUtils.sendEmail(sendEmailMessage);
					}
				}
			}
		}
    }
    
    /**
     * excel荷兰订单数据插入
     * @param cloudList
     * @return
     * @throws Exception
     * @throws InterruptedException
     */
    public Long insertExcelDataBefore (List<StyleDesignHistoryEntity> cloudList,String customName,Long venderID,
    		String orderType,String dataSourceFlag, Date targetDateMTM,String orderDate) throws Exception,InterruptedException{
    	stopFlag = false;
    	
    	if (cloudList != null && cloudList.size()>0) {
    		// 获取所有质检项目（34整烫前、35整烫后、36半成品尺寸、37成品尺寸）
    		List<CheckQualityEntity> allQualityItemList = checkQualityDao.findAllSetItem(new CheckQualityEntity());
    		//
    		List <DesignOption> designOptionsList = findDesignOption (new Order());
    	    List <StyleOptionEntity> sizeUnitCostList = findSizeUnitCost ();
    	    List <StyleOptionEntity> qualityControlList = findQualityControl ();
    		// 订单list
    		List <Order> orderList = new ArrayList <> ();
    		// 款式list
    		List <BigcargoStyle> styleList = new ArrayList <> ();
    		// 款式实体类
    		BigcargoStyle bigcargoStyle = new BigcargoStyle ();
    		StyleFit styleFit = new StyleFit ();
    		List <OrderTempTableEntity> orderTempTableEntityList = new ArrayList <> ();
    		OrderTempTableEntity orderTempTableEntity = new OrderTempTableEntity ();
    		for (int i = 0; i < cloudList.size(); i++) {
    			if (cloudList.get(i) != null) {
    				orderList.add(addOrderInfo(cloudList.get(i),orderType,dataSourceFlag));
    				bigcargoStyle = addStyleInfo(cloudList.get(i),orderType);
    				// 设计项目嵌套集合
    				Map<String, Object> mapDesign = addOptionInfo(cloudList.get(i), qualityControlList, sizeUnitCostList,dataSourceFlag);
    				bigcargoStyle.setOptionEntityList ((List <StyleOptionEntity>)mapDesign.get("styleOptionList"));
    				if ("ERP".equals(dataSourceFlag)) {
    					styleFit.setStyleSizeGruop ("GROUP_SIZE-EGS_GROUP_SIZE");
    					styleFit.setStyleSizeCd ("EGS_GROUP_SIZE-" + cloudList.get(i).getShirtSize().trim ());
    				}else if("MTM".equals(dataSourceFlag)){
    					styleFit.setStyleSizeGruop (cloudList.get(i).getSizeGroup());
    					styleFit.setStyleSizeCd (cloudList.get(i).getSizeCd());
    				}
    				// 量体信息嵌套集合
    				Map<String, Object> mapFit = addFitInfo(cloudList.get(i),venderID);
    				styleFit.setFitValue ((String)mapFit.get("fitValue"));
    				styleFit.setItemCd (ResourcesUtil.getConfig ("style_fit_code"));
    				styleFit.setItemValue (ResourcesUtil.getConfig ("style_fit_value"));
    				styleFit.setItemValueMTM(cloudList.get(i).getItemValueMTM());
    				styleFit.setInValue(cloudList.get(i).getInValue());
    				styleFit.setOutValue(cloudList.get(i).getOutValue());
    				// 设置质检数据集
    				bigcargoStyle.setStyleControlList (addQCInfo(cloudList.get(i),allQualityItemList,(Map<String, String>)mapFit.get("fitList"),(Map<String, String>)mapDesign.get("designList"),orderType));
                    if ("ERP".equals(dataSourceFlag)) {
                    	bigcargoStyle.setCostEntityList (addCostInfoERP(cloudList.get(i),designOptionsList));
                    }else if("MTM".equals(dataSourceFlag)){
                    	bigcargoStyle.setCostEntityList (addCostInfoMTM(cloudList.get(i)));
                    }
                    bigcargoStyle.setStyleFit (styleFit);
                    styleList.add (bigcargoStyle);
                    bigcargoStyle = new BigcargoStyle ();
                    styleFit = new StyleFit ();
    			}
    		}
    		return insertExcelData (styleList, orderList, orderTempTableEntityList,customName,venderID,orderType,dataSourceFlag,targetDateMTM,orderDate);
		}
    	return null;
    }
    		
    /**
     * 添加Order 信息
     * @param cloudEntity
     * @return StyleOptionEntity
     */
    public Order addOrderInfo(StyleDesignHistoryEntity cloudEntity,String orderType,String dataSourceFlag){
    	// 订单实体类
		Order order = new Order ();
		order.setOrderNO (cloudEntity.getOrderNo());
		if ("ERP".equals(dataSourceFlag)) {
			order.setOrderTypeCD (orderType);
        }else if("MTM".equals(dataSourceFlag)){
        	order.setOrderTypeCD (ResourcesUtil.getConfig ("order_type-type_20"));
        }
		order.setUrgentCD (cloudEntity.getUrgentOrder());
		order.setOrderStatusCD ("T.S.Y");
		order.setOrderDate (cloudEntity.getOrderDate());
		order.setTryonOrder (cloudEntity.getTryonOrder());
		order.setCustomerName (cloudEntity.getCustomerName());
		order.setSpecialOder (cloudEntity.getSpecialOrder());
		// 日本大货 和 荷兰小样
        if (ResourcesUtil.getConfig("order_type-type_50").equals(orderType)) {
        	order.setShopId(new Long(cloudEntity.getShopName()));
        }else {
        	order.setShopId(new Long(cloudEntity.getShopId()));
		}
		order.setShopName (cloudEntity.getShopName());
		order.setShippingDestintion (cloudEntity.getShippingDestination());
		order.setShipmentDate (cloudEntity.getShipmentDate());
		// 日本大货 和 荷兰小样
        if (ResourcesUtil.getConfig("order_type-type_50").equals(orderType)
        		|| ResourcesUtil.getConfig("order_type-type_60").equals(orderType)) {
        	order.setRealDate(cloudEntity.getRealDate());
        }
		order.setSleeveFlag(cloudEntity.getSleeveFlag());
		order.setCustomOrderNo(cloudEntity.getCustomOrderNo());
		order.setCustomName(cloudEntity.getCustomName());
		order.setMakeShirt(cloudEntity.getCustomMakeShirt());
		order.setTransitGroup(cloudEntity.getTransitGroup());
		order.setCountryName(cloudEntity.getCountry());
		order.setMaterialSource(cloudEntity.getMaterialSource()+"");
		order.setRemarks(cloudEntity.getRemarks());
		// 交易号条码
		order.setStyleBarCode(cloudEntity.getBusinessBarCode());
		// 交易号
		order.setBusinessNo(cloudEntity.getBusinessNo());
		// 交易号订单数
		order.setAccountingOrderSize(cloudEntity.getAccountingOrderSize());
		// 设置收货地址信息
		order.setAddresseeName(cloudEntity.getAddresseeName());
		order.setAddresseeTel(cloudEntity.getAddresseeTel());
		order.setAddressProvinceCd(cloudEntity.getAddressProvinceCd());
		order.setAddressCityCd(cloudEntity.getAddressCityCd());
		order.setAddressDistrict(cloudEntity.getAddressDistrict());
		order.setAddressDetail(cloudEntity.getAddressDetail());
		order.setZipCode(cloudEntity.getZipCode());
		order.setBarInfo(cloudEntity.getBarInfo());
		return order;
    }
    
    /**
     * 添加Order 信息
     * @param cloudEntity
     * @return StyleOptionEntity
     */
    public BigcargoStyle addStyleInfo(StyleDesignHistoryEntity cloudEntity,String orderType){
    	// 款式实体类
        BigcargoStyle bigcargoStyle = new BigcargoStyle ();
        bigcargoStyle.setStyleCateGoryCd (cloudEntity.getOrderParts());
        bigcargoStyle.setStyleFabricNo (cloudEntity.getFabricCode());
        bigcargoStyle.setStyleComposition (cloudEntity.getFabricComposition());
        String[] styleName = cloudEntity.getStyleNameCn().replace(":", ",").replace("：", ",").split(",");
        if(styleName.length > 1){
        	bigcargoStyle.setStyleNameCn (styleName[1]);
        }else {
        	bigcargoStyle.setStyleNameCn (styleName[0]);
		}
        bigcargoStyle.setStyleMakeType (ResourcesUtil.getConfig ("shirt_4sma") + "-" + cloudEntity.getModelSma());
        bigcargoStyle.setFitBodyType ("FIT_BODY_TYPE-" + cloudEntity.getModelShm());
        bigcargoStyle.setStyleSizeGroupCn ("EGS_GROUP_SIZE-" + cloudEntity.getShirtSize());
        bigcargoStyle.setSizeGroup ("GROUP_SIZE-EGS_GROUP_SIZE");
        if (cloudEntity.getQuantity() != null) {
        	bigcargoStyle.setRemarks(cloudEntity.getQuantity().toString());
		}
        // 日本大货 和 荷兰大货
        if (ResourcesUtil.getConfig("order_type-type_50").equals(orderType)
        		|| ResourcesUtil.getConfig("order_type-type_60").equals(orderType)) {
        	bigcargoStyle.setRemarks(cloudEntity.getPrice());
        }
        return bigcargoStyle;
    }
    
    /**
     * 量体项目数据处理
     *
     * @param val
     * @return
     */
    public String sizeSpecialHandle(String val,Long venderID) {
    	// 量体项目数据转换
    	String value = valuechangeInt (val);
    	// Pacific客户
    	if (venderID == 113) {
    		String[] valArray = value.split(".");
    		if (valArray.length > 1) {
    			String decimal = valArray[1];
    			// 小数位为1或2则舍
    			if ("1".equals(decimal) || "2".equals(decimal)) {
    				value = valArray[0];
    			// 小数位为7或8或9则进位
    			}else if ("7".equals(decimal) || "8".equals(decimal) || "9".equals(decimal)) {
    				value = String.valueOf(Integer.parseInt(valArray[0]) + 1);
    			// 小数位为3或4或5或6则取0.5
    			}else {
    				value = valArray[0] + ".5";
    			}
    		}
		}
    	// 返回数据
        return value;
    }
    
    /**
     * 添加fit信息
     * @param cloudEntity
     * @return StyleOptionEntity
     */
    public Map<String, Object> addFitInfo(StyleDesignHistoryEntity cloudEntity,Long venderID){
    	//
    	Map<String, Object> returnMap = new HashMap<>();
    	// 
    	Map<String, String> map = new HashMap<>();
    	// 量体项目实际值
    	String fitValue = "";
    	// 1.胸围
    	String circu_item_02 = sizeSpecialHandle (cloudEntity.getSize12che(),venderID);
    	fitValue += circu_item_02 + ",";
    	map.put("SHIRT_CIRCU001-CIRCU_ITEM_02", circu_item_02);
    	// 2.腰围
    	String circu_item_05 = sizeSpecialHandle (cloudEntity.getSize12wai(),venderID);
    	fitValue += circu_item_05 + ",";
    	map.put("SHIRT_CIRCU001-CIRCU_ITEM_05", circu_item_05);
    	// 3.底摆
    	String circu_item_06 = sizeSpecialHandle (cloudEntity.getSize12hip(),venderID);
    	fitValue += circu_item_06 + ",";
    	map.put("SHIRT_CIRCU001-CIRCU_ITEM_06", circu_item_06);
    	// 4.肩宽
    	String circu_item_07 = sizeSpecialHandle (cloudEntity.getSizeYok(),venderID);
    	fitValue += circu_item_07 + ",";
    	map.put("SHIRT_CIRCU001-CIRCU_ITEM_07", circu_item_07);
    	// 5.后衣长 
    	String lengt_item_02 = sizeSpecialHandle (cloudEntity.getSizeLen(),venderID);
    	fitValue += lengt_item_02 + ",";
    	map.put("SHIRT_LENGT002-LENGT_ITEM_02", lengt_item_02);
    	// 6.领围
    	String circu_item_01 = sizeSpecialHandle (cloudEntity.getSizeCol(),venderID);
    	fitValue += circu_item_01 + ",";
    	map.put("SHIRT_CIRCU001-CIRCU_ITEM_01", circu_item_01);
    	// 7.大臂围
    	String lengt_item_08 = sizeSpecialHandle (cloudEntity.getSizeUam(),venderID);
    	fitValue += lengt_item_08 + ",";
    	map.put("SHIRT_CIRCU001-LENGT_ITEM_08", lengt_item_08);
    	// 8.左小臂围
    	String lengt_item_09 = sizeSpecialHandle (cloudEntity.getSizeFal(),venderID);
    	fitValue += lengt_item_09 + ",";
    	map.put("SHIRT_CIRCU001-LENGT_ITEM_09", lengt_item_09);
    	// 9.右小臂围
    	String lengt_item_10 = sizeSpecialHandle (cloudEntity.getSizeFar(),venderID);
    	fitValue += lengt_item_10 + ",";
    	map.put("SHIRT_CIRCU001-LENGT_ITEM_10", lengt_item_10);
    	// 10.左袖头围缩小
    	String circu_item_15 = sizeSpecialHandle (cloudEntity.getSizeScl(),venderID);
    	fitValue += circu_item_15 + ",";
    	map.put("SHIRT_CIRCU001-CIRCU_ITEM_15", circu_item_15);
    	// 11.右袖头围缩小
    	String circu_item_16 = sizeSpecialHandle (cloudEntity.getSizeScr(),venderID);
    	fitValue += circu_item_16 + ",";
    	map.put("SHIRT_CIRCU001-CIRCU_ITEM_16", circu_item_16);
    	// 12.左袖头围左
    	String circu_item_17 = sizeSpecialHandle (cloudEntity.getSizeCll(),venderID);
    	fitValue += circu_item_17 + ",";
    	map.put("SHIRT_CIRCU001-CIRCU_ITEM_17", circu_item_17);
    	// 13.右袖头围右
    	String circu_item_18 = sizeSpecialHandle (cloudEntity.getSizeClr(),venderID);
    	fitValue += circu_item_18 + ",";
    	map.put("SHIRT_CIRCU001-CIRCU_ITEM_18", circu_item_18);
    	// 18.左肩底
    	String circu_item_19 = sizeSpecialHandle (cloudEntity.getSizeLsl(),venderID);
    	fitValue += circu_item_19 + ",";
    	map.put("SHIRT_POSTU003-CIRCU_ITEM_19", circu_item_19);
    	// 14.左袖短
    	String circu_item_20 = sizeSpecialHandle (cloudEntity.getSizeSsl(),venderID);
    	fitValue += circu_item_20 + ",";
    	map.put("SHIRT_CIRCU001-CIRCU_ITEM_20", circu_item_20);
    	// 19.右肩底
    	String circu_item_21 = sizeSpecialHandle (cloudEntity.getSizeLsr(),venderID);
    	fitValue += circu_item_21 + ",";
    	map.put("SHIRT_POSTU003-CIRCU_ITEM_21", circu_item_21);
    	// 15.右袖短
    	String circu_item_22 = sizeSpecialHandle (cloudEntity.getSizeSsr(),venderID);
    	fitValue += circu_item_22 + ",";
    	map.put("SHIRT_CIRCU001-CIRCU_ITEM_22", circu_item_22);
    	// 20.前立扣位
    	String postu_item_06 = valuechangeInt (cloudEntity.getSizeRbh());
    	fitValue += postu_item_06 + ",";
    	map.put("SHIRT_POSTU003-POSTU_ITEM_06", postu_item_06);
    	// 16.左袖长左
    	String postu_item_07 = sizeSpecialHandle (cloudEntity.getSizeSll(),venderID);
    	fitValue += postu_item_07 + ",";
    	map.put("SHIRT_LENGT002-POSTU_ITEM_07", postu_item_07);
    	// 21.前立扣数
    	String postu_item_08 = valuechangeInt (cloudEntity.getSizeBof());
    	fitValue += postu_item_08 + ",";
    	map.put("SHIRT_POSTU003-POSTU_ITEM_08", postu_item_08);
    	// 17.右袖长右
    	String postu_item_09 = sizeSpecialHandle (cloudEntity.getSizeSlr(),venderID);
    	fitValue += postu_item_09;
    	map.put("SHIRT_LENGT002-POSTU_ITEM_09", postu_item_09);
    	//
    	returnMap.put("fitValue", fitValue);
    	returnMap.put("fitList", map);
    	//
		return returnMap;
    }
    
    /**
     * 添加style_quality_control质检信息
     * @param cloudEntity
     * @return StyleOptionEntity
     */
    public List<StyleOptionEntity> addQCInfo(StyleDesignHistoryEntity cloudEntity,List<CheckQualityEntity> allQualityItemList,Map<String,String> fitList,Map<String,String> designList,String orderType){
    	// 服装款式信息实体类
    	StyleOptionEntity styleOptionEntity = new StyleOptionEntity ();
    	// 服装款式信息list
    	List<StyleOptionEntity> styleControlList = new ArrayList<>();
    	String designValueTemp = "";
    	String fitValueTemp = "";
    	if (allQualityItemList != null && allQualityItemList.size() > 0) {
			for(CheckQualityEntity cEntity : allQualityItemList){
				// 标准质检项目id
				styleOptionEntity.setQcItemId(cEntity.getQcId());
				// 工序id
				styleOptionEntity.setQcOperatingId(cEntity.getOperatingId());
				// 质检项目名称
				styleOptionEntity.setQcItem (cEntity.getQcItem());
				// 质检项目code
				styleOptionEntity.setItemCode (cEntity.getQcItemCd());
				// 质检项目value
				styleOptionEntity.setItemValue (cEntity.getQcItemValue());
				// 订单条形码
				styleOptionEntity.setStyleBarCode(cloudEntity.getOrderNo().substring(cloudEntity.getOrderNo().lastIndexOf(".")+1,cloudEntity.getOrderNo().length()));
				// 设置质检项目实际数据值
				// 洗涤订单号
				if (ResourcesUtil.getConfig ("qc_order").equals(cEntity.getQcItemCd())
						&& ResourcesUtil.getConfig ("qc_qorno").equals(cEntity.getQcItemValue())) {
					styleOptionEntity.setOptionValue (cloudEntity.getOrderNo());
				// 面料号
				}else if (ResourcesUtil.getConfig ("qc_material_no").equals(cEntity.getQcItemCd())
						&& ResourcesUtil.getConfig ("qc_qmano").equals(cEntity.getQcItemValue())) {
					styleOptionEntity.setOptionValue (cloudEntity.getFabricCode());
				// 设计项目、量体项目和其他特殊项
				}else {
					// 获取设计项目值
					designValueTemp = designList.get(cEntity.getQcItemCd()+"-"+cEntity.getQcItemValue());
					// 获取量体项目值
					fitValueTemp = fitList.get(cEntity.getQcItemCd()+"-"+cEntity.getQcItemValue());
					// 设置数据
					// 设计项目
					if (designValueTemp != null) {
						// 线色弹力线数据特殊处理 并设置备注信息
						if ("4THN1,4THN2,4THN3,4THN4".indexOf(cEntity.getQcItemValue()) != -1
								&& designValueTemp.indexOf("弹力线") != -1) {
							styleOptionEntity.setOptionValue(designValueTemp.split("\\(")[1].replace(")", ""));
							styleOptionEntity.setRemarks(designValueTemp);
						// 扣 设置备注信息
						}else if (ResourcesUtil.getConfig ("shirt_design_sbu").equals(cEntity.getQcItemCd())
								&& ResourcesUtil.getConfig ("shirt_sbu").equals(cEntity.getQcItemValue())) {
							styleOptionEntity.setOptionValue(designValueTemp.split("SBU_REMARKS")[0]);
							styleOptionEntity.setRemarks(designValueTemp.split("SBU_REMARKS")[1]);
						}else {
							styleOptionEntity.setOptionValue (designValueTemp);
						}
					// 量体项目
					}else if (fitValueTemp != null) {
						// 量体项目为 左袖长左 时数据特殊处理
						if (ResourcesUtil.getConfig ("SHIRT_LENGT002").equals(cEntity.getQcItemCd())
								&& ResourcesUtil.getConfig ("POSTUITEM07").equals(cEntity.getQcItemValue())) {
							// 袖头
					        String scuStr = cloudEntity.getModelScu();
					        // 左袖长
					        String sllStr = cloudEntity.getSizeSll();
							//非小样订单
					        if ("".equals(cloudEntity.getSampleFlag())) {
					        	if (!"".equals(scuStr)&&!"-".equals(scuStr)&&!"--".equals(scuStr)) {
					        		if ("MaCuNO".equals(scuStr)) {
					        			scuStr = "6.5";
					        		}else {
					        			if (ResourcesUtil.getConfig ("order_type-type_10").equals(orderType)) {
					        				scuStr = scuStr.split(" ")[0].trim();
					        				scuStr = scuStr.substring(scuStr.length()-1, scuStr .length());
										}
					        		}
					        		if (ResourcesUtil.getConfig ("order_type-type_10").equals(orderType)) {
						        		sllStr = Double.parseDouble(sllStr) - Double.parseDouble(scuStr) + "";
					        		}
					        	}
							}
					        styleOptionEntity.setOptionValue (sllStr);
						// 右袖长右
						}else if (ResourcesUtil.getConfig ("SHIRT_LENGT002").equals(cEntity.getQcItemCd())
								&& ResourcesUtil.getConfig ("POSTUITEM09").equals(cEntity.getQcItemValue())) {
							// 袖头
							String scuStr = cloudEntity.getModelScu();
							// 右袖长
					        String slrStr = cloudEntity.getSizeSlr();
					        //非小样订单
					        if ("".equals(cloudEntity.getSampleFlag())) {
						        if (!"".equals(scuStr)&&!"-".equals(scuStr)&&!"--".equals(scuStr)) {
						        	if ("MaCuNO".equals(scuStr)) {
					        			scuStr = "6.5";
					        		}else {
					        			if (ResourcesUtil.getConfig ("order_type-type_10").equals(orderType)) {
					        				scuStr = scuStr.split(" ")[0].trim();
					        				scuStr = scuStr.substring(scuStr.length()-1, scuStr .length());
					        			}
					        		}
						        	if (ResourcesUtil.getConfig ("order_type-type_10").equals(orderType)) {
						        		slrStr = Double.parseDouble(slrStr) - Double.parseDouble(scuStr) + "";
						        	}
						        }
					        }
					        styleOptionEntity.setOptionValue (slrStr);
						// 其它量体项目
						}else {
							styleOptionEntity.setOptionValue (fitValueTemp);
						}
					// 其它项目
					}else {
						styleOptionEntity.setOptionValue ("—");
					}
				}
		        styleControlList.add (styleOptionEntity);
		        styleOptionEntity = new StyleOptionEntity ();
			}
		}
        //返回数据集
		return styleControlList;
    }
    
    /**
     * 添加style_option质检信息
     * @param cloudEntity
     * @return StyleOptionEntity
     */
    public Map<String, Object> addOptionInfo(StyleDesignHistoryEntity cloudEntity,List<StyleOptionEntity> qualityControlList,List<StyleOptionEntity> sizeUnitCostList,String dataSourceFlag){
    	//
    	Map<String, Object> returnMap = new HashMap<>();
    	//
    	Map<String, String> map = new HashMap<>();
    	// 服装款式信息实体类
    	StyleOptionEntity styleOptionEntity = new StyleOptionEntity ();
    	StyleOptionEntity styleOption = new StyleOptionEntity ();
    	// 服装款式信息list
    	List<StyleOptionEntity> styleControlList = new ArrayList<>();
        // 款式制作工艺 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sma"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_4sma"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSma());
        styleControlList.add (styleOptionEntity);
        styleOptionEntity = new StyleOptionEntity ();
        map.put(ResourcesUtil.getConfig ("shirt_design_sma")+"-"+ResourcesUtil.getConfig ("shirt_4sma"), cloudEntity.getModelSma());
        /*---------------------特殊项 衬衫规格 -----start----------------------------------- */
        // 衬衫规格 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_4ssize"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_4size"));
        styleOptionEntity.setOptionValue (cloudEntity.getShirtSize());
        styleControlList.add (styleOptionEntity);
        styleOptionEntity = new StyleOptionEntity ();
        map.put(ResourcesUtil.getConfig ("shirt_4ssize")+"-"+ResourcesUtil.getConfig ("shirt_4size"), cloudEntity.getShirtSize());
        /*----------------------特殊项 衬衫规格------end----------------------------------- */
        // 缝制线 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_thread"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_thread"));
        styleOptionEntity.setOptionValue (cloudEntity.getTrimThdno());
        styleControlList.add (styleOptionEntity);
        styleOptionEntity = new StyleOptionEntity ();
        map.put(ResourcesUtil.getConfig ("shirt_design_thread")+"-"+ResourcesUtil.getConfig ("shirt_thread"), cloudEntity.getTrimThdno());
        // 款式版型 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_shm"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_shm"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelShm());
        styleControlList.add (styleOptionEntity);
        styleOptionEntity = new StyleOptionEntity ();
        map.put(ResourcesUtil.getConfig ("shirt_design_shm")+"-"+ResourcesUtil.getConfig ("shirt_shm"), cloudEntity.getModelShm());
        // 线号 optionEntityList
        styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sgd") + "-" + ResourcesUtil.getConfig ("shirt_sgd"));
        if (styleOption != null) {
            styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
        }
        styleOption = new StyleOptionEntity ();
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sgd"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sgd"));
        styleOptionEntity.setOptionValue (cloudEntity.getTrimSgd());
        styleControlList.add (styleOptionEntity);
        styleOptionEntity = new StyleOptionEntity ();
        map.put(ResourcesUtil.getConfig ("shirt_design_sgd")+"-"+ResourcesUtil.getConfig ("shirt_sgd"), cloudEntity.getTrimSgd());
        // 袖子 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_ssl"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_ssl"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSsl());
        styleControlList.add (styleOptionEntity);
        styleOptionEntity = new StyleOptionEntity ();
        map.put(ResourcesUtil.getConfig ("shirt_design_ssl")+"-"+ResourcesUtil.getConfig ("shirt_ssl"), cloudEntity.getModelSsl());
        //扣 optionEntityList
        //小扣 
        String smallSbu = "0";
        //大扣
        String bigSbu = "0";
        //领子扣
        String scoBtn = "0";
        //备注
        String remarkStr = "";
        Map<String, Object> mapSbu = new HashMap<>();
		if ("ERP".equals(dataSourceFlag)) {
			mapSbu = countSbuNum(cloudEntity,sizeUnitCostList);
			
		}else if ("MTM".equals(dataSourceFlag)){
			mapSbu = countSbuNumMTM(cloudEntity,sizeUnitCostList);
		}
        smallSbu = mapSbu.get("smallSbu").toString();
        bigSbu = mapSbu.get("bigSbu").toString();
        scoBtn = mapSbu.get("scoCost").toString();
        remarkStr = mapSbu.get("remarkStr").toString();
        styleOptionEntity.setMaterialUnitCost ((Integer.parseInt(bigSbu) + Integer.parseInt(smallSbu)) + "");
        styleOptionEntity.setRemarks (remarkStr);
        styleOptionEntity.setOptionCost1 (smallSbu + "," + bigSbu + "," + scoBtn);
        styleOptionEntity.setScoBtnNum(scoBtn);
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sbu"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sbu"));
        styleOptionEntity.setOptionValue (cloudEntity.getTrimSbu());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sbu")+"-"+ResourcesUtil.getConfig ("shirt_sbu"), styleOptionEntity.getOptionValue()+"SBU_REMARKS"+remarkStr);
        styleOptionEntity = new StyleOptionEntity ();
        // 领子 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sco"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sco"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSco());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sco")+"-"+ResourcesUtil.getConfig ("shirt_sco"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 扣眼颜色 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sbh"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sbh_colour"));
        String sbhStr = cloudEntity.getTrimSbh();
        if (sbhStr.indexOf("(")!=-1) {
        	styleOptionEntity.setRemarks(sbhStr);
        	sbhStr = sbhStr.split("\\(")[1].replace(")", "");
		}
        styleOptionEntity.setOptionValue (sbhStr);
        styleOptionEntity.setRemarks(countBHNum(cloudEntity,sizeUnitCostList)+"");
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sbh")+"-"+ResourcesUtil.getConfig ("shirt_sbh_colour"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 袖头 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_scu"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_scu"));
        String scuStr = cloudEntity.getModelScu();
        if ("-".equals(scuStr)||"--".equals(scuStr)) {
        	scuStr = "";
		}
        styleOptionEntity.setOptionValue (scuStr);
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_scu")+"-"+ResourcesUtil.getConfig ("shirt_scu"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 订扣 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sat"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sat"));
        styleOptionEntity.setOptionValue (cloudEntity.getTrimSat());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sat")+"-"+ResourcesUtil.getConfig ("shirt_sat"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 袖开祺 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_ssv"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_ssv"));
        String ssvStr = cloudEntity.getModelSsv();
        if ("-".equals(ssvStr)||"--".equals(ssvStr)) {
        	ssvStr = "";
		}
        styleOptionEntity.setOptionValue (ssvStr);
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_ssv")+"-"+ResourcesUtil.getConfig ("shirt_ssv"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 订扣线颜色 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sbt"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sbt_colour"));
        styleOptionEntity.setOptionValue (cloudEntity.getTrimSbt());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sbt")+"-"+ResourcesUtil.getConfig ("shirt_sbt_colour"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 衬布 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_ssk"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_ssk"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSsk());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_ssk")+"-"+ResourcesUtil.getConfig ("shirt_ssk"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 衬布颜色
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sskcl"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("sskcl_4thn5"));
        if (ResourcesUtil.getConfig("ssk_color_black").indexOf(cloudEntity.getFabricCode()) != -1) {
            styleOptionEntity.setOptionValue (ResourcesUtil.getConfig ("sskcl_4thn5_black"));
		}else if (ResourcesUtil.getConfig("ssk_color_gray").indexOf(cloudEntity.getFabricCode()) != -1) {
            styleOptionEntity.setOptionValue (ResourcesUtil.getConfig ("sskcl_4thn5_gray"));
		}else {
            styleOptionEntity.setOptionValue (ResourcesUtil.getConfig ("sskcl_4thn5_white"));
		}
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sskcl")+"-"+ResourcesUtil.getConfig ("sskcl_4thn5"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 领子，袖头配色线 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sts"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sts_colour"));
        styleOptionEntity.setOptionValue (cloudEntity.getTrimSts());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sts")+"-"+ResourcesUtil.getConfig ("shirt_sts_colour"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 领插签 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sbo"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sbo"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSbo());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sbo")+"-"+ResourcesUtil.getConfig ("shirt_sbo"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 台领下夹牙绳 optionEntityList
        if (!"".equals (cloudEntity.getTrimSbi())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sbi") + "-" + ResourcesUtil.getConfig ("shirt_sbi"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sbi"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sbi"));
        styleOptionEntity.setOptionValue (cloudEntity.getTrimSbi());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sbi")+"-"+ResourcesUtil.getConfig ("shirt_sbi"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 前立optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sfp"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sfp"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSfp().replace(".", "").trim());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sfp")+"-"+ResourcesUtil.getConfig ("shirt_sfp"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 胸兜  optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sbp"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sbp"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSbp());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sbp")+"-"+ResourcesUtil.getConfig ("shirt_sbp"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 后背款式  optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sba"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sba"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSba());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sba")+"-"+ResourcesUtil.getConfig ("shirt_sba"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 水洗要求 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_washed"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_washed"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelWash());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_washed")+"-"+ResourcesUtil.getConfig ("shirt_washed"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 领子，袖口明线 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sst"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sst"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSst());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sst")+"-"+ResourcesUtil.getConfig ("shirt_sst"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 包装方法 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_packaging"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_packaging"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSpck());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_packaging")+"-"+ResourcesUtil.getConfig ("shirt_packaging"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 手绢 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_spo"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_spo"));
        // 若手绢位置数据为空，则判断手绢配料位置数据，若有值，则根据制作方式设置数据，若为空则设置为无手绢
        if ("".equals(cloudEntity.getModelSpo())) {
        	if (!"".equals(cloudEntity.getContSc9())) {
        		if (cloudEntity.getModelSma().indexOf("4M") != -1 || cloudEntity.getModelSma().indexOf("SM") != -1
        				|| cloudEntity.getModelSma().indexOf("BM") != -1) {
        			// 机缝手绢
        			styleOptionEntity.setOptionValue("4POYES");
                } else if (cloudEntity.getModelSma().indexOf("4H") != -1 || cloudEntity.getModelSma().indexOf("SH") != -1) {
                	// 手缝手绢
                	styleOptionEntity.setOptionValue("4PHYES");
                }
        	}else {
        		// 无手绢
        		styleOptionEntity.setOptionValue("4PONO");
        	}
		}else {
			styleOptionEntity.setOptionValue (cloudEntity.getModelSpo());
		}
        
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_spo")+"-"+ResourcesUtil.getConfig ("shirt_spo"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // Ribbon optionEntityList
        if (!"".equals (cloudEntity.getModelRibb())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_ribbon") + "-" + ResourcesUtil.getConfig ("shirt_ribbon"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_ribbon"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_ribbon"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelRibb());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_ribbon")+"-"+ResourcesUtil.getConfig ("shirt_ribbon"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 后省 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sbd"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sbd"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSbd());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sbd")+"-"+ResourcesUtil.getConfig ("shirt_sbd"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 过肩 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sbj"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sbj"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSbj());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sbj")+"-"+ResourcesUtil.getConfig ("shirt_sbj"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 底摆款式 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sbs"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sbs"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelSbs());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sbs")+"-"+ResourcesUtil.getConfig ("shirt_sbs"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 小号 optionEntityList
        if (!"".equals (cloudEntity.getLablSize())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sizelabel") + "-" + ResourcesUtil.getConfig ("shirt_sizelabel"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sizelabel"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sizelabel"));
        String suiFlag = "false";
        if ("ERP".equals(dataSourceFlag)) {
        	if (cloudEntity.getLablSize().toUpperCase().indexOf("YES") != -1 || cloudEntity.getLablSize().toUpperCase().indexOf("有") != -1) {
        		String orderStr = cloudEntity.getOrderNo().toLowerCase();
        		if (orderStr.indexOf("sui")!=-1 && orderStr.indexOf("suitt") == -1 ) {
        			
        			styleOptionEntity.setOptionValue ("SU-" + cloudEntity.getShirtSize());
        			suiFlag = "true";
        		/*}else if (orderStr.indexOf("hq")!=-1) {*/
        		}else {
        			if ("pacific-1".equals(cloudEntity.getLablSizeType().toLowerCase())) {
        				String lableSize = cloudEntity.getLablSize().toUpperCase().replace("YES / 有", "").trim();
        				styleOptionEntity.setOptionValue(cloudEntity.getLablSizeType()+"-"+lableSize);
        			}else {
        				styleOptionEntity.setOptionValue ("LG-" + cloudEntity.getShirtSize());
					}
        		}
        	}
		}else if ("MTM".equals(dataSourceFlag)) {
			if (!"".equals(cloudEntity.getLablSize()) && cloudEntity.getLablSize() != null) {
				styleOptionEntity.setOptionValue (cloudEntity.getLablSize());
        	}
		}
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sizelabel")+"-"+ResourcesUtil.getConfig ("shirt_sizelabel"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 小号种类
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sizelabelt"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_sizelabelt"));
        // 如果小号种类为空且属于SUI订单，则赋值'SS'。
        if ("".equals(cloudEntity.getLablSizeType()) && "true".equals(suiFlag)) {
        	styleOptionEntity.setOptionValue ("SS");
		}else {
			styleOptionEntity.setOptionValue (cloudEntity.getLablSizeType());
		}
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sizelabelt")+"-"+ResourcesUtil.getConfig ("shirt_sizelabelt"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 台领里配料 optionEntityList
        if (!"".equals (cloudEntity.getContSc1())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc1") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc1"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc1"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_contrast_sc1"));
        styleOptionEntity.setOptionValue (cloudEntity.getContSc1());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc1")+"-"+ResourcesUtil.getConfig ("shirt_contrast_sc1"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 后领中订商标 optionEntityList
        if (!"".equals (cloudEntity.getLablLp1())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_lp01") + "-" + ResourcesUtil.getConfig ("shirt_slc_lp01"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_lp01"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_slc_lp01"));
        // 如果后领中订为空且属于SUI订单，则赋值'SU-82'。
        if ("".equals(cloudEntity.getLablLp1()) && "true".equals(suiFlag)) {
        	styleOptionEntity.setOptionValue ("SU-82");
		}else {
			styleOptionEntity.setOptionValue (cloudEntity.getLablLp1());
		}
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_lp01")+"-"+ResourcesUtil.getConfig ("shirt_slc_lp01"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        //  羽领，台领配料 optionEntityList
        if (!"".equals (cloudEntity.getContSc2())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc2") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc2"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc2"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_contrast_sc2"));
        styleOptionEntity.setOptionValue (cloudEntity.getContSc2());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc2")+"-"+ResourcesUtil.getConfig ("shirt_contrast_sc2"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 三角布 optionEntityList
        if (!"".equals (cloudEntity.getLablLp2())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_lp02") + "-" + ResourcesUtil.getConfig ("shirt_slc_lp02"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_lp02"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_slc_lp02"));
        styleOptionEntity.setOptionValue (cloudEntity.getLablLp2());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_lp02")+"-"+ResourcesUtil.getConfig ("shirt_slc_lp02"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 袖头里配料 optionEntityList
        if (!"".equals (cloudEntity.getContSc3())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc3") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc3"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc3"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_contrast_sc3"));
        styleOptionEntity.setOptionValue (cloudEntity.getContSc3());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc3")+"-"+ResourcesUtil.getConfig ("shirt_contrast_sc3"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 上前立里侧订商标 optionEntityList
        if (!"".equals (cloudEntity.getLablLp3())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_lp03") + "-" + ResourcesUtil.getConfig ("shirt_slc_lp03"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_lp03"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_slc_lp03"));
        styleOptionEntity.setOptionValue (cloudEntity.getLablLp3());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_lp03")+"-"+ResourcesUtil.getConfig ("shirt_slc_lp03"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        //  袖头配料 optionEntityList
        if (!"".equals (cloudEntity.getContSc4())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc4") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc4"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc4"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_contrast_sc4"));
        styleOptionEntity.setOptionValue (cloudEntity.getContSc4());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc4")+"-"+ResourcesUtil.getConfig ("shirt_contrast_sc4"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 下前立里侧订商标 optionEntityList
        if (!"".equals (cloudEntity.getLablLp4())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_lp04") + "-" + ResourcesUtil.getConfig ("shirt_slc_lp04"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_lp04"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_slc_lp04"));
        styleOptionEntity.setOptionValue (cloudEntity.getLablLp4());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_lp04")+"-"+ResourcesUtil.getConfig ("shirt_slc_lp04"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        //  台领配料 optionEntityList
        if (!"".equals (cloudEntity.getContSc5())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc5") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc5"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc5"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_contrast_sc5"));
        styleOptionEntity.setOptionValue (cloudEntity.getContSc5());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc5")+"-"+ResourcesUtil.getConfig ("shirt_contrast_sc5"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 大布订商标 optionEntityList
        if (!"".equals (cloudEntity.getLablLp5())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_lp05") + "-" + ResourcesUtil.getConfig ("shirt_slc_lp05"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_lp05"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_slc_lp05"));
        styleOptionEntity.setOptionValue (cloudEntity.getLablLp5());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_lp05")+"-"+ResourcesUtil.getConfig ("shirt_slc_lp05"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 上前立表配料 optionEntityList
        if (!"".equals (cloudEntity.getContSc6())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc6") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc6"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc6"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_contrast_sc6"));
        styleOptionEntity.setOptionValue (cloudEntity.getContSc6());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc6")+"-"+ResourcesUtil.getConfig ("shirt_contrast_sc6"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 后领缝商标 optionEntityList
        if (!"".equals (cloudEntity.getLablLp6())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_lp06") + "-" + ResourcesUtil.getConfig ("shirt_slc_lp06"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_lp06"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_slc_lp06"));
        styleOptionEntity.setOptionValue (cloudEntity.getLablLp6());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_lp06")+"-"+ResourcesUtil.getConfig ("shirt_slc_lp06"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 下前立配料 optionEntityList
        if (!"".equals (cloudEntity.getContSc7())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc7") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc7"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc7"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_contrast_sc7"));
        styleOptionEntity.setOptionValue (cloudEntity.getContSc7());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc7")+"-"+ResourcesUtil.getConfig ("shirt_contrast_sc7"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 吊牌 optionEntityList
        String hasStr = cloudEntity.getLablHas();
        if (cloudEntity.getOrderNo().toUpperCase().indexOf("SUI")!=-1 
        		&& cloudEntity.getOrderNo().toUpperCase().indexOf("SUITT") == -1 ) {
        	hasStr = "SP-3";
		}
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_hangtag"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_hangtag"));
        styleOptionEntity.setOptionValue (hasStr);
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_hangtag")+"-"+ResourcesUtil.getConfig ("shirt_hangtag"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 袖补强布配料 optionEntityList
        if (!"".equals (cloudEntity.getContSc8())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc8") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc8"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc8"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_contrast_sc8"));
        styleOptionEntity.setOptionValue (cloudEntity.getContSc8());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc8")+"-"+ResourcesUtil.getConfig ("shirt_contrast_sc8"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 洗涤成分 optionEntityList
        String clStr = cloudEntity.getLablCl();
        if (!"".equals (clStr)) {
        	if (cloudEntity.getShopName().toUpperCase().indexOf("SUIT") != -1) {
        		clStr = "SUIT-" + clStr;
        	}else if (cloudEntity.getFabricCode().toUpperCase().indexOf("KNIT") != -1 
        			|| ResourcesUtil.getConfig ("knit_other_fabric").indexOf(cloudEntity.getFabricCode().toUpperCase()) != -1) {
        		clStr = "KNIT-" + clStr;
        	}else if (cloudEntity.getLablCoo().replace(" ", "").toUpperCase().indexOf("ROS") != -1) {
        		clStr = clStr + "-CA00572";
        	// 洗涤种类
        	}else if (cloudEntity.getLablClt().toLowerCase().indexOf("pacific") != -1) {
        		// 若洗涤种类为Pacific，则在后面拼接上洗涤成分
        		clStr = cloudEntity.getLablClt() + "-" + clStr;
    		}
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_carelabel") + "-" + ResourcesUtil.getConfig ("shirt_carelabel"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_carelabel"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_carelabel"));
        styleOptionEntity.setOptionValue (clStr);
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_carelabel")+"-"+ResourcesUtil.getConfig ("shirt_carelabel"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 手绢配料 optionEntityList
        if (!"".equals (cloudEntity.getContSc9())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc9") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc9"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc9"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_contrast_sc9"));
        // 若手绢配料为'本料'，则设置为当前订单的面料数据
        if ("本料".equals(cloudEntity.getContSc9())) {
        	cloudEntity.setContSc9(cloudEntity.getFabricCode());
		}
        styleOptionEntity.setOptionValue (cloudEntity.getContSc9());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc9")+"-"+ResourcesUtil.getConfig ("shirt_contrast_sc9"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // Care label type 洗涤种类 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_labeltype"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_labeltype"));
        styleOptionEntity.setOptionValue (cloudEntity.getLablClt());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_labeltype")+"-"+ResourcesUtil.getConfig ("shirt_labeltype"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 大布配料 optionEntityList
        if (!"".equals (cloudEntity.getContSc0())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc0"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_contrast_sc0"));
        styleOptionEntity.setOptionValue (cloudEntity.getContSc0());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+ResourcesUtil.getConfig ("shirt_contrast_sc0"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 产地标 optionEntityList
        if (!"".equals (cloudEntity.getLablCoo())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_country") + "-" + ResourcesUtil.getConfig ("shirt_country"));
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
            styleOption = new StyleOptionEntity ();
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_country"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("shirt_country"));
        if ("ERP".equals(dataSourceFlag)) {
        	// 正常订单
        	if ("".equals(cloudEntity.getSampleFlag())) {
        		if ("无产地标".equals (cloudEntity.getLablCoo().split ("/")[1].trim ())) {
        			styleOptionEntity.setOptionValue ("");
        		} else {
        			styleOptionEntity.setOptionValue (cloudEntity.getLablCoo().split ("/")[1].trim ());
        		}
        	// 小样订单
			}else {
				styleOptionEntity.setOptionValue ("");
			}
		}else if ("MTM".equals(dataSourceFlag)) {
			styleOptionEntity.setOptionValue (cloudEntity.getLablCoo());
		}
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_country")+"-"+ResourcesUtil.getConfig ("shirt_country"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 刺绣内容optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_monogram_sco"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("4smt"));
        styleOptionEntity.setOptionValue (cloudEntity.getEmbrText());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_monogram_sco")+"-"+ResourcesUtil.getConfig ("4smt"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 刺绣颜色 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_monogram_smc"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("4smc"));
        styleOptionEntity.setOptionValue (cloudEntity.getEmbrSmc());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_monogram_smc")+"-"+ResourcesUtil.getConfig ("4smc"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 字体 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_monogram_smo"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("4smo"));
        styleOptionEntity.setOptionValue (cloudEntity.getEmbrSmo());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_monogram_smo")+"-"+ResourcesUtil.getConfig ("4smo"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 刺绣位置 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_monogram_smp"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("4smp"));
        styleOptionEntity.setOptionValue (cloudEntity.getEmbrSmp().replace (" ", ""));
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_monogram_smp")+"-"+ResourcesUtil.getConfig ("4smp"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        // 刺绣大小 optionEntityList
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_monogram_sms"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("4sms"));
        styleOptionEntity.setOptionValue (cloudEntity.getEmbrSms().replace (" ", ""));
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_monogram_sms")+"-"+ResourcesUtil.getConfig ("4sms"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        
        // 物料线迹
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_stitch"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("stitch"));
        styleOptionEntity.setOptionValue (cloudEntity.getModelStitch());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_stitch")+"-"+ResourcesUtil.getConfig ("stitch"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        
        // 面料标
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_label_fabric"));
        styleOptionEntity.setItemValue (ResourcesUtil.getConfig ("fabric"));
        styleOptionEntity.setOptionValue (cloudEntity.getLablFabric());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_label_fabric")+"-"+ResourcesUtil.getConfig ("fabric"), styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        /**********************************/
        // 台领、羽领配料 optionEntityList
        if (!"".equals (cloudEntity.getContJpA())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_A");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_A");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpA());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_A", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
     // 上前身（左）+左面三角布 optionEntityList
        if (!"".equals (cloudEntity.getContJpHSB())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_HSB");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_HSB");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpHSB());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_HSB", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
     // 下前身（右）+右面三角布 optionEntityList
        if (!"".equals (cloudEntity.getContJpHSC())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_HSC");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_HSC");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpHSC());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_HSC", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
     // 左袖+左大小布 optionEntityList
        if (!"".equals (cloudEntity.getContJpHSD())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_HSD");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_HSD");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpHSD());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_HSD", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
     // 右袖+右大小布 optionEntityList
        if (!"".equals (cloudEntity.getContJpHSE())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_HSE");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_HSE");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpHSE());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_HSE", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
     // 左袖头 optionEntityList
        if (!"".equals (cloudEntity.getContJpHSF())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_HSF");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_HSF");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpHSF());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_HSF", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
     // 右袖头 optionEntityList
        if (!"".equals (cloudEntity.getContJpHSG())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_HSG");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_HSG");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpHSG());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_HSG", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
     // 兜  optionEntityList
        if (!"".equals (cloudEntity.getContJpH1())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_H1");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_H1");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpH1());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_H1", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
     // 育克（表里） optionEntityList
        if (!"".equals (cloudEntity.getContJpI())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_I");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_I");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpI());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_I", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
     // 后片+小鼻 optionEntityList
        if (!"".equals (cloudEntity.getContJpJ())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_J");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_J");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpJ());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_J", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
     // 前片+两侧三角布  optionEntityList
        if (!"".equals (cloudEntity.getContJpB())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_B");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_B");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpB());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_B", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
     // 左袖 optionEntityList
        if (!"".equals (cloudEntity.getContJpD())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_D");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_D");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpD());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_D", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
     // 右袖 optionEntityList
        if (!"".equals (cloudEntity.getContJpE())) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + "JP_E");
            if (styleOption != null) {
                styleOptionEntity.setMaterialUnitCost (styleOption.getMaterialUnitCost ());
            }
        }
        styleOptionEntity.setItemCode (ResourcesUtil.getConfig ("shirt_design_sc0"));
        styleOptionEntity.setItemValue ("JP_E");
        styleOptionEntity.setOptionValue (cloudEntity.getContJpE());
        styleControlList.add (styleOptionEntity);
        map.put(ResourcesUtil.getConfig ("shirt_design_sc0")+"-"+"JP_E", styleOptionEntity.getOptionValue());
        styleOptionEntity = new StyleOptionEntity ();
        /**********************************/
        //
        returnMap.put("designList", map);
        returnMap.put("styleOptionList", styleControlList);
        //
		return returnMap;
    }
    
    /**
     * 添加style_cost订单费用信息
     * @param cloudEntity
     * @return StyleOptionEntity
     */
    public List<StyleCostEntity> addCostInfoERP(StyleDesignHistoryEntity cloudEntity,List <DesignOption> designOptionsList){
    	// 服装款式费用实体类
        StyleCostEntity styleCostEntity = new StyleCostEntity ();
        // 服装款式费用list
        List <StyleCostEntity> costEntityList = new ArrayList <> ();
        //斜纹
        if (ResourcesUtil.getConfig ("twill_material").indexOf (cloudEntity.getFabricCode())>0) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("material_twill_cost")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("material_style_twill"));
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
         
        //对格
        } else if (ResourcesUtil.getConfig ("grid_material").indexOf (cloudEntity.getFabricCode())>0) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("material_grid_cost")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("material_style_grid"));
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        //对条
        } else if (ResourcesUtil.getConfig ("strip_material").indexOf (cloudEntity.getFabricCode())>0) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("material_strip_cost")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("material_style_strip"));
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        // 凡是针织面料
        } else if (cloudEntity.getFabricCode().toUpperCase().indexOf("KNIT") != -1 
    			|| ResourcesUtil.getConfig ("knit_other_fabric").indexOf(cloudEntity.getFabricCode().toUpperCase()) != -1) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("headStr_knit_cost")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("head_str_knit"));
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("spec_composition_cost")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("material_knit"));
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
         //特殊面料
        } else if (ResourcesUtil.getConfig ("special_material").indexOf(cloudEntity.getFabricCode())>0) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("spec_composition_cost")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("spec_matrial"));
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();      
        }
        // 新版
        if (cloudEntity.getStyleNameCn().indexOf("NEW") != -1) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("new_shirt_cost")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_4snew") + "-" + ResourcesUtil.getConfig ("shirt_4new"));
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 缝制方式
        String makeType = ResourcesUtil.getConfig ("shirt_4sma") + "-" + cloudEntity.getModelSma().trim ();
        if (cloudEntity.getModelSma().indexOf("4M") != -1 || cloudEntity.getModelSma().indexOf("SM") != -1) {
            if (cloudEntity.getStyleNameCn().indexOf("NEW") != -1) {
                styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("new_traditonal")));
                styleCostEntity.setCostType ("0");
                styleCostEntity.setCostItem1 (makeType);
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
            } else if (cloudEntity.getStyleNameCn().indexOf("OLD") != -1) {
                styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("old_traditonal")));
                styleCostEntity.setCostType ("0");
                styleCostEntity.setCostItem1 (makeType);
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
            }
        } else if (cloudEntity.getModelSma().indexOf("4H") != -1 || cloudEntity.getModelSma().indexOf("SH") != -1) {
            String getCost = returnCost (designOptionsList, cloudEntity.getModelSma());
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (makeType);
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        } else if (cloudEntity.getModelSma().indexOf("BM") != -1) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("bm_traditonal")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (makeType);
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 缝制线
        if ("G0008".equals (cloudEntity.getTrimThdno()) || "K403".equals (cloudEntity.getTrimThdno())) {
            styleCostEntity.setCostValue (new BigDecimal (3));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_thread") + "-" + cloudEntity.getTrimThdno());
            styleCostEntity.setRemark ("shirt_thdno");
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        } else {
            styleCostEntity.setCostValue (new BigDecimal (4));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_thread") + "-" + cloudEntity.getTrimThdno());
            styleCostEntity.setRemark ("shirt_thdno");
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 线号
        String getCost = returnCost (designOptionsList, cloudEntity.getTrimSgd());
        if (!"0".equals (getCost)) {
            if ("4GDCA".equals (cloudEntity.getTrimSgd())) {
                styleCostEntity.setCostValue (new BigDecimal (getCost));
                styleCostEntity.setCostType ("0");
                styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sgd") + "-" + cloudEntity.getTrimSgd());
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
            }
        }
        //袖子
        if ("4SLLO2".equals(cloudEntity.getModelSsl().replace(".", "").trim())) {
        	//机缝
        	if (makeType.equals (ResourcesUtil.getConfig ("make_type_4m")) || makeType.equals (ResourcesUtil.getConfig ("make_type_sm")) || makeType.equals (ResourcesUtil.getConfig ("make_type_bm"))) {
        		styleCostEntity.setCostValue (new BigDecimal (4));
        		styleCostEntity.setCostType ("1");
        		styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_ssl") + "-" + cloudEntity.getModelSsl().replace(".", ""));
        		costEntityList.add (styleCostEntity);
        		styleCostEntity = new StyleCostEntity ();
        		//手缝
        	} else if (makeType.equals (ResourcesUtil.getConfig ("make_type_sh")) || makeType.equals (ResourcesUtil.getConfig ("make_type_4h"))) {
        		styleCostEntity.setCostValue (new BigDecimal (8));
        		styleCostEntity.setCostType ("1");
        		styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_ssl") + "-" + cloudEntity.getModelSsl().replace(".", ""));
        		costEntityList.add (styleCostEntity);
        		styleCostEntity = new StyleCostEntity ();
        	}
		}
        //扣
        if (cloudEntity.getModelSco().indexOf("4COBB") != -1) {
            styleCostEntity.setCostValue (new BigDecimal (4));
            styleCostEntity.setCostType ("1");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sco") + "-" + cloudEntity.getModelSco());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        //袖头
        //机缝
        if (makeType.equals (ResourcesUtil.getConfig ("make_type_4m")) || makeType.equals (ResourcesUtil.getConfig ("make_type_sm"))  || makeType.equals (ResourcesUtil.getConfig ("make_type_bm"))) {
            if (cloudEntity.getModelScu().indexOf ("DR7") != -1 || cloudEntity.getModelScu().indexOf ("DH7") != -1 || cloudEntity.getModelScu().indexOf ("SM7") != -1 || cloudEntity.getModelScu().indexOf ("DS7") != -1) {
                styleCostEntity.setCostValue (new BigDecimal (3.6));
                styleCostEntity.setCostType ("1");
                styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_scu") + "-" + cloudEntity.getModelScu());
                styleCostEntity.setCostItem2 (makeType);
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
            }
            //手缝
        } else if (makeType.equals (ResourcesUtil.getConfig ("make_type_sh")) || makeType.equals (ResourcesUtil.getConfig ("make_type_4h"))) {
            if (cloudEntity.getModelScu().indexOf ("DR7") != -1 || cloudEntity.getModelScu().indexOf ("DH7") != -1 || cloudEntity.getModelScu().indexOf ("SM7") != -1 || cloudEntity.getModelScu().indexOf ("DS7") != -1) {
                styleCostEntity.setCostValue (new BigDecimal (4.8));
                styleCostEntity.setCostType ("1");
                styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_scu") + "-" + cloudEntity.getModelScu());
                styleCostEntity.setCostItem2 (makeType);
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
            }
        }
        //订扣
        getCost = returnCost (designOptionsList, cloudEntity.getTrimSat());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sat") + "-" + cloudEntity.getTrimSat());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        //袖开祺
        getCost = returnCost (designOptionsList, cloudEntity.getModelSsv());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_ssv") + "-" + cloudEntity.getModelSsv());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 订扣线颜色
        if (!"G0008".equals (cloudEntity.getTrimSbh()) && !"K403".equals (cloudEntity.getTrimSbh()) && !"G0008".equals (cloudEntity.getTrimSbt()) && !"K403".equals (cloudEntity.getTrimSbt())) {
            if (!cloudEntity.getTrimSbh().equals (cloudEntity.getTrimSbt())) {
                styleCostEntity.setCostValue (new BigDecimal (4));
                styleCostEntity.setCostType ("0");
                styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sbh_colour") + "-" + cloudEntity.getTrimSbh());
                styleCostEntity.setRemark ("shirt_sbh");
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
                styleCostEntity.setCostValue (new BigDecimal (4));
                styleCostEntity.setCostType ("0");
                styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sbt_colour") + "-" + cloudEntity.getTrimSbt());
                styleCostEntity.setRemark ("shirt_sbt");
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
            } else if (cloudEntity.getTrimSbh().equals (cloudEntity.getTrimSbt())) {
                styleCostEntity.setCostValue (new BigDecimal (4));
                styleCostEntity.setCostType ("0");
                styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sbh_colour") + "-" + cloudEntity.getTrimSbh());
                styleCostEntity.setRemark ("shirt_sbh");
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
            }
        } else if (!"G0008".equals (cloudEntity.getTrimSbh()) && !"K403".equals (cloudEntity.getTrimSbh()) && ("G0008".equals (cloudEntity.getTrimSbt()) || "K403".equals (cloudEntity.getTrimSbt()))) {
            styleCostEntity.setCostValue (new BigDecimal (4));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sbh_colour") + "-" + cloudEntity.getTrimSbh());
            styleCostEntity.setRemark ("shirt_sbh");
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        } else if (!"G0008".equals (cloudEntity.getTrimSbt()) && !"K403".equals (cloudEntity.getTrimSbt()) && ("G0008".equals (cloudEntity.getTrimSbh()) || "K403".equals (cloudEntity.getTrimSbh()))) {
            styleCostEntity.setCostValue (new BigDecimal (4));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sbt_colour") + "-" + cloudEntity.getTrimSbt());
            styleCostEntity.setRemark ("shirt_sbt");
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 衬布 (新版没有衬布钱)
        getCost = returnCost (designOptionsList, cloudEntity.getModelSsk());
        if (!"0".equals (getCost)) {
            if (cloudEntity.getStyleNameCn().indexOf("OLD") != -1) {
                styleCostEntity.setCostValue (new BigDecimal (getCost));
                styleCostEntity.setCostType ("0");
                styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_ssk") + "-" + cloudEntity.getModelSsk());
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
            }
        }
        // 领子，袖头配色线
        if (cloudEntity.getTrimSts().indexOf("A") == 0) {
            styleCostEntity.setCostValue (new BigDecimal (5));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sts_colour") + "-" + cloudEntity.getTrimSts());
            styleCostEntity.setRemark ("shirt_sts");
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        } else if (cloudEntity.getTrimSts().indexOf("T") == 0) {
            if (!cloudEntity.getTrimThdno().equals (cloudEntity.getTrimSts().substring (1, cloudEntity.getTrimSts().length () - 1).trim ())) {
                styleCostEntity.setCostValue (new BigDecimal (4));
                styleCostEntity.setCostType ("0");
                styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sts_colour") + "-" + cloudEntity.getTrimSts());
                styleCostEntity.setRemark ("shirt_sts");
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
            }
        }
        // 领插签
        getCost = returnCost (designOptionsList, cloudEntity.getModelSbo());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sbo") + "-" + cloudEntity.getModelSbo());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 台领下夹牙绳
        if (!"".equals (cloudEntity.getTrimSbi())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("bies_collar_cost")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_design_sbi") + "-" + ResourcesUtil.getConfig ("shirt_sbi"));
            styleCostEntity.setRemark (cloudEntity.getTrimSbi());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 前立
        getCost = returnCost (designOptionsList, cloudEntity.getModelSfp());
        if (!"0".equals (getCost)) {
            if (ResourcesUtil.getConfig ("sfp_1fppoo").equals (cloudEntity.getModelSfp())) {
                styleCostEntity.setCostValue (new BigDecimal (getCost));
                styleCostEntity.setCostType ("0");
                styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sfp") + "-" + cloudEntity.getModelSfp());
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
            }
        }
        // 胸兜
        getCost = returnCost (designOptionsList, cloudEntity.getModelSbp());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sbp") + "-" + cloudEntity.getModelSbp());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 后背款式
        getCost = returnCost (designOptionsList, cloudEntity.getModelSba());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sba") + "-" + cloudEntity.getModelSba());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 水洗要求
        if (!"4WANO".equals (cloudEntity.getModelWash()) && !"".equals (cloudEntity.getModelWash())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("washed_cost")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_washed") + "-" + cloudEntity.getModelWash());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 领子，袖口明线
        getCost = returnCost (designOptionsList, cloudEntity.getModelSst());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sst") + "-" + cloudEntity.getModelSst());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 包装方法
        getCost = returnCost (designOptionsList, cloudEntity.getModelSpck());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_packaging") + "-" + cloudEntity.getModelSfp());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        //薄纸
        getCost = returnCost (designOptionsList, ResourcesUtil.getConfig ("packaging_tissue"));
        styleCostEntity.setCostValue (new BigDecimal (getCost));
        styleCostEntity.setCostType ("0");
        styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_packaging") + "-" + ResourcesUtil.getConfig ("packaging_tissue"));
        costEntityList.add (styleCostEntity);
        styleCostEntity = new StyleCostEntity ();
        //印号
        getCost = returnCost (designOptionsList, ResourcesUtil.getConfig ("packaging_mark"));
        styleCostEntity.setCostValue (new BigDecimal (getCost));
        styleCostEntity.setCostType ("0");
        styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_packaging") + "-" + ResourcesUtil.getConfig ("packaging_mark"));
        costEntityList.add (styleCostEntity);
        styleCostEntity = new StyleCostEntity ();
        // 手绢
        if (!"4PONO".equals (cloudEntity.getModelSpo())) {
        	//机缝
            if (makeType.equals (ResourcesUtil.getConfig ("make_type_4m")) || makeType.equals (ResourcesUtil.getConfig ("make_type_sm")) || makeType.equals (ResourcesUtil.getConfig ("make_type_bm"))) {
                styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("pochet_traditonal")));
                styleCostEntity.setCostType ("1");
                styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_spo") + "-" + cloudEntity.getModelSpo());
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
                //手缝
            } else if (makeType.equals (ResourcesUtil.getConfig ("make_type_sh")) || makeType.equals (ResourcesUtil.getConfig ("make_type_4h"))) {
                styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("pochet_handmade")));
                styleCostEntity.setCostType ("1");
                styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_spo") + "-" + cloudEntity.getModelSpo());
                costEntityList.add (styleCostEntity);
                styleCostEntity = new StyleCostEntity ();
            }
        }
        // Ribbon
        getCost = returnCost (designOptionsList, cloudEntity.getModelRibb());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_ribbon") + "-" + cloudEntity.getModelRibb());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 后省
        getCost = returnCost (designOptionsList, cloudEntity.getModelSbd());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sbd") + "-" + cloudEntity.getModelSbd());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 过肩
        getCost = returnCost (designOptionsList, cloudEntity.getModelSbj());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sbj") + "-" + cloudEntity.getModelSbj());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 底摆款式
        getCost = returnCost (designOptionsList, cloudEntity.getModelSbs());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sbs") + "-" + cloudEntity.getModelSbs());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 小号
        getCost = returnCost (designOptionsList, cloudEntity.getLablSize());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_sizelabel") + "-" + cloudEntity.getLablSize().replaceAll ("[^0-9]", ""));
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 台领里配料
        if (!"".equals (cloudEntity.getContSc1())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_design_sc1") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc1"));
            styleCostEntity.setRemark (cloudEntity.getContSc1());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 后领中订商标
        getCost = returnCost (designOptionsList, cloudEntity.getLablLp1());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_slc_lp01") + "-" + cloudEntity.getLablLp1());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 羽领，台领配料
        if (!"".equals (cloudEntity.getContSc2())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_design_sc2") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc2"));
            styleCostEntity.setRemark (cloudEntity.getContSc2());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 三角布
        getCost = returnCost (designOptionsList, cloudEntity.getLablLp2());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_slc_lp02") + "-" + cloudEntity.getLablLp2());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        //  袖头里配料
        if (!"".equals (cloudEntity.getContSc3())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_design_sc3") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc3"));
            styleCostEntity.setRemark (cloudEntity.getContSc3());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 上前立里侧订商标
        getCost = returnCost (designOptionsList, cloudEntity.getLablLp3());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_slc_lp03") + "-" + cloudEntity.getLablLp3());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 袖头配料
        if (!"".equals (cloudEntity.getContSc4())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_design_sc4") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc4"));
            styleCostEntity.setRemark (cloudEntity.getContSc4());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 下前立里侧订商标
        getCost = returnCost (designOptionsList, cloudEntity.getLablLp4());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_slc_lp04") + "-" + cloudEntity.getLablLp4());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 台领配料
        if (!"".equals (cloudEntity.getContSc5())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_design_sc5") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc5"));
            styleCostEntity.setRemark (cloudEntity.getContSc5());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 大布订商标
        getCost = returnCost (designOptionsList, cloudEntity.getLablLp5());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_slc_lp05") + "-" + cloudEntity.getLablLp5());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 上前立表配料
        if (!"".equals (cloudEntity.getContSc6())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_design_sc6") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc6"));
            styleCostEntity.setRemark (cloudEntity.getContSc6());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 后领缝商标
        getCost = returnCost (designOptionsList, cloudEntity.getLablLp6());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_slc_lp06") + "-" + cloudEntity.getLablLp6());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 下前立配料
        if (!"".equals (cloudEntity.getContSc7())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_design_sc7") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc7"));
            styleCostEntity.setRemark (cloudEntity.getContSc7());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 吊牌
        getCost = returnCost (designOptionsList, cloudEntity.getLablHas());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_hangtag") + "-" + cloudEntity.getLablHas());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 袖补强布配料
        if (!"".equals (cloudEntity.getContSc8())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_design_sc8") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc8"));
            styleCostEntity.setRemark (cloudEntity.getContSc8());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 洗涤成分
        getCost = returnCost (designOptionsList, cloudEntity.getLablCl());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_carelabel") + "-" + cloudEntity.getLablCl());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 手绢配料
        if (!"".equals (cloudEntity.getContSc9())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_design_sc9") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc9"));
            styleCostEntity.setRemark (cloudEntity.getContSc9());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // Care label type
        getCost = returnCost (designOptionsList, cloudEntity.getLablClt());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_labeltype") + "-" + cloudEntity.getLablClt());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 大布配料
        if (!"".equals (cloudEntity.getContSc0())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_design_sc0") + "-" + ResourcesUtil.getConfig ("shirt_contrast_sc0"));
            styleCostEntity.setRemark (cloudEntity.getContSc0());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 产地标
        getCost = returnCost (designOptionsList, cloudEntity.getLablCoo());
        if (!"0".equals (getCost)) {
            styleCostEntity.setCostValue (new BigDecimal (getCost));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_country") + "-" + cloudEntity.getLablCoo());
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        // 刺绣内容
        if (!"".equals (cloudEntity.getEmbrText())) {
            styleCostEntity.setCostValue (new BigDecimal (ResourcesUtil.getConfig ("embroidery_text")));
            styleCostEntity.setCostType ("0");
            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_monogram_sco") + "-" + ResourcesUtil.getConfig ("4smt"));
            costEntityList.add (styleCostEntity);
            styleCostEntity = new StyleCostEntity ();
        }
        //左袖头围左 ≠ 右袖头围右
        if (!"".equals (cloudEntity.getSizeClr())) {
        	if ((new BigDecimal(cloudEntity.getSizeCll())).compareTo(new BigDecimal(cloudEntity.getSizeClr())) != 0) {
        		styleCostEntity.setCostValue (new BigDecimal (1.65));
        		styleCostEntity.setCostType ("1");
        		styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_4ssize") + "-" + ResourcesUtil.getConfig ("shirt_4size"));
        		styleCostEntity.setCostItem2 (ResourcesUtil.getConfig ("style_fit_code").split (",")[11] + "-" + ResourcesUtil.getConfig ("style_fit_value").split (",")[11]);
        		styleCostEntity.setCostItem3 (ResourcesUtil.getConfig ("style_fit_code").split (",")[12] + "-" + ResourcesUtil.getConfig ("style_fit_value").split (",")[12]);
        		styleCostEntity.setRemark ("shirt_cuff");
        		costEntityList.add (styleCostEntity);
        		styleCostEntity = new StyleCostEntity ();
        	} 
		}
        //左袖长 ≠ 右袖长
        if (!"".equals (cloudEntity.getSizeSlr())) {
	        if ((new BigDecimal(cloudEntity.getSizeSll())).compareTo(new BigDecimal(cloudEntity.getSizeSlr())) != 0) {
	            styleCostEntity.setCostValue (new BigDecimal (1.65));
	            styleCostEntity.setCostType ("1");
	            styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_4ssize") + "-" + ResourcesUtil.getConfig ("shirt_4size"));
	            styleCostEntity.setCostItem2 (ResourcesUtil.getConfig ("style_fit_code").split (",")[18] + "-" + ResourcesUtil.getConfig ("style_fit_value").split (",")[18]);
	            styleCostEntity.setCostItem3 (ResourcesUtil.getConfig ("style_fit_code").split (",")[20] + "-" + ResourcesUtil.getConfig ("style_fit_value").split (",")[20]);
	            styleCostEntity.setRemark ("shirt_sleeve");
	            costEntityList.add (styleCostEntity);
	            styleCostEntity = new StyleCostEntity ();
	        }
        }
        //左肩高≠ 右肩高
        if (!"".equals (cloudEntity.getSizeSlr())) {
        	if ((new BigDecimal(cloudEntity.getSizeLsl())).compareTo(new BigDecimal(cloudEntity.getSizeLsr())) != 0) {
        		styleCostEntity.setCostValue (new BigDecimal (1.65));
        		styleCostEntity.setCostType ("1");
        		styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_4ssize") + "-" + ResourcesUtil.getConfig ("shirt_4size"));
        		styleCostEntity.setCostItem2 (ResourcesUtil.getConfig ("style_fit_code").split (",")[13] + "-" + ResourcesUtil.getConfig ("style_fit_value").split (",")[13]);
        		styleCostEntity.setCostItem3 (ResourcesUtil.getConfig ("style_fit_code").split (",")[15] + "-" + ResourcesUtil.getConfig ("style_fit_value").split (",")[15]);
        		styleCostEntity.setRemark ("shirt_shoulder");
        		costEntityList.add (styleCostEntity);
        		styleCostEntity = new StyleCostEntity ();
        	}
        }
        return costEntityList;
    }
    
    /**
     * 添加style_cost订单费用信息MTM
     * @param cloudEntity
     * @return StyleOptionEntity
     */
    public List<StyleCostEntity> addCostInfoMTM(StyleDesignHistoryEntity cloudEntity){
    	// 服装款式费用实体类
        StyleCostEntity styleCostEntity = new StyleCostEntity ();
        // 服装款式费用list
        List <StyleCostEntity> costEntityList = new ArrayList <> ();
        //原辅料费用
        try{
            styleCostEntity.setCostValue (new BigDecimal(cloudEntity.getMaterialCost()));
        }catch (Exception e) {
            styleCostEntity.setCostValue(new BigDecimal(0.0));
            logger.info("cloudEntity.getMaterialCost():"+cloudEntity.getMaterialCost());
        }

        styleCostEntity.setCostType ("0");
        styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("mtm_material_cost"));
        costEntityList.add (styleCostEntity);
        styleCostEntity = new StyleCostEntity ();
        //设计费用
        if (cloudEntity.getDesignCostCode() != null && !"".equals(cloudEntity.getDesignCostCode())) {
        	//设计项目code集
			String[] codeList = cloudEntity.getDesignCostCode().split(",");
			//设计项目value集
			String[] valueList = cloudEntity.getDesignCostValue().split(",");
			//设计项目费用集
			String[] costList = cloudEntity.getDesignCostCost().split(",");
			for (int i = 0; i < costList.length; i++) {
				styleCostEntity.setCostValue (new BigDecimal(costList[i]));
		        styleCostEntity.setCostType ("0");
		        styleCostEntity.setCostItem1 (codeList[i] + "-" + valueList[i]);
		        costEntityList.add (styleCostEntity);
		        styleCostEntity = new StyleCostEntity ();
			}
		}
        //缝制费用
        /*if ("4M".equals(cloudEntity.getModelSma()) || "SM".equals(cloudEntity.getModelSma())) {
        	styleCostEntity.setCostValue (new BigDecimal(ResourcesUtil.getConfig ("new_traditonal")));
        }else if("BM".equals(cloudEntity.getModelSma())){
        	styleCostEntity.setCostValue (new BigDecimal(ResourcesUtil.getConfig ("new_simple_traditonal")));
		}else{
			styleCostEntity.setCostValue (new BigDecimal(ResourcesUtil.getConfig ("new_handle")));
		}
        styleCostEntity.setCostType ("0");
        styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("shirt_4sma") + "-" + cloudEntity.getModelSma().trim ());
        costEntityList.add (styleCostEntity);
        styleCostEntity = new StyleCostEntity ();*/
        //其他费用
        /*styleCostEntity.setCostValue (new BigDecimal(ResourcesUtil.getConfig ("mtm_other_cost_num")));
        styleCostEntity.setCostType ("0");
        styleCostEntity.setCostItem1 (ResourcesUtil.getConfig ("mtm_other_cost"));
        costEntityList.add (styleCostEntity);
        styleCostEntity = new StyleCostEntity ();*/
        return costEntityList;
    }
    
    /**
     *  扣的计算(erp)
     * @return
     */
    public Map<String, Object> countSbuNum(StyleDesignHistoryEntity cloudEntity,List<StyleOptionEntity> sizeUnitCostList) {
    	Map<String, Object> map = new HashMap<>();
    	StyleOptionEntity styleOption = new StyleOptionEntity (); 
    	//小扣 
        int smallSbu = 0;
        //大扣
        int bigSbu = 0;
        //金属扣
        int metalSbu = 0;
        //备注
        String remarkStr = "";
        //领子扣
        String shirtScocellStr = cloudEntity.getModelSco();
        String scoCost = "0";
        if (!"".equals (shirtScocellStr)) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_sco") + "-" + shirtScocellStr);
            if (styleOption != null) {
                scoCost = styleOption.getMaterialUnitCost ();
                smallSbu = smallSbu + (int)Double.parseDouble(scoCost);
            }
            //如果领子为4COCA3 2或4COBD3 2，大扣加2，否则加1
            /*if ("4COCA3 2,4COBD3 2".indexOf(shirtScocellStr) != -1) {
            	bigSbu = bigSbu + 2;
            }else {
            	bigSbu = bigSbu + 1;
            }*/
        }
        //袖开祺扣
        String shirtSvvcellStr = cloudEntity.getModelSsv();
        String ssvCost = "0";
        if (!"".equals (shirtSvvcellStr)) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_ssv") + "-" + shirtSvvcellStr);
            if (styleOption != null) {
                ssvCost = styleOption.getMaterialUnitCost ();
            }
        }
        smallSbu = smallSbu + (int)Double.parseDouble(ssvCost);
        if (smallSbu != 0) {
			smallSbu = smallSbu + 1;
        }
        /*if ("4SV04".equals(shirtSvvcellStr)) { 
    		if (shirtScocellStr.indexOf("4COBD") != -1 || shirtScocellStr.indexOf("4COBB") != -1) {
    			smallSbu = 3;
			}else {
				smallSbu = 0;
			 }
		}*/
        remarkStr += "小扣：" + smallSbu + " ";
        //袖头扣
        String shirtScucellStr = cloudEntity.getModelScu();
        String scuCost = "0";
        if (!"".equals (shirtScucellStr)) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_scu") + "-" + shirtScucellStr);
            if (styleOption != null) {
                scuCost = styleOption.getMaterialUnitCost ();
            }
        }
        //后衣长
        String shirtLengthcellStr = cloudEntity.getSizeLen();
        //前立
        String shirtSfpcellStr = cloudEntity.getModelSfp();
        //前立扣数
        String shirtBofcellStr = cloudEntity.getSizeBof();
        int sfpCost = 0;
        if (!"".equals (shirtLengthcellStr)) {
        	//如果前立为4FPA00、4FPC00、4FPB35或4FPB25，按照订单前立扣数数据取值。
        	//如果前立为4FPPOL，则前立扣数为2，其它的前立扣数为4。
        	//如果前立为4FPC00、4FPD00、4FPG00或4FPF00，则有4颗金属扣。
        	if ("4FPD00,4FPG00,4FPF00,4FPPOP".indexOf(shirtSfpcellStr) != -1) {
        			sfpCost = 4;
					//sfpCost = (int)Double.parseDouble(shirtBofcellStr) - 4;
					if ("4FPD00,4FPG00,4FPF00".indexOf(shirtSfpcellStr) != -1) {
						metalSbu = 4;
					}
			}else if ("4FPPOL".equals(shirtSfpcellStr)){
				//styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_sfp") + "-" + shirtSfpcellStr);
	            /*if (styleOption != null) {
	            	sfpCost = (int)Double.parseDouble(styleOption.getMaterialUnitCost ());
	            }*/
				sfpCost = 2;
			}else {
				if ("4FPC00".equals(shirtSfpcellStr)) {
					sfpCost = (int)Double.parseDouble(shirtBofcellStr);
					//metalSbu = 4;
				}else {
					sfpCost = (int)Double.parseDouble(shirtBofcellStr);
				}
			}
        }
        bigSbu = bigSbu + (int)Double.parseDouble(scuCost) + sfpCost;
        if (bigSbu != 0) {
            bigSbu = bigSbu + 1;
            remarkStr += "大扣：" + bigSbu;
        }
        if (metalSbu != 0) {
        	remarkStr += " 金属扣：" + metalSbu;
		}
        map.put("bigSbu", bigSbu);
        map.put("smallSbu", smallSbu);
        map.put("remarkStr", remarkStr);
        map.put("scoCost", (int)Double.parseDouble(scoCost));
		return map;
	}
    
    /**
     *  扣的计算(MTM)
     * @return
     */
    public Map<String, Object> countSbuNumMTM(StyleDesignHistoryEntity cloudEntity,List<StyleOptionEntity> sizeUnitCostList) {
    	Map<String, Object> map = new HashMap<>();
    	StyleOptionEntity styleOption = new StyleOptionEntity (); 
    	//小扣 
        int smallSbu = 0;
        //大扣
        int bigSbu = 0;
        //金属扣
        int metalSbu = 0;
        //备注
        String remarkStr = "";
        //领子扣
        String shirtScocellStr = cloudEntity.getModelSco();
        String scoCost = "0";
        if (!"".equals (shirtScocellStr)) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_sco") + "-" + shirtScocellStr);
            if (styleOption != null) {
                scoCost = styleOption.getMaterialUnitCost ();
                smallSbu = smallSbu + (int)Double.parseDouble(scoCost);
            }
        }
        //袖开祺扣
        String shirtSvvcellStr = cloudEntity.getModelSsv();
        String ssvCost = "0";
        if (!"".equals (shirtSvvcellStr)) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_ssv") + "-" + shirtSvvcellStr);
            if (styleOption != null) {
                ssvCost = styleOption.getMaterialUnitCost ();
            }
        }
        smallSbu = smallSbu + (int)Double.parseDouble(ssvCost);
        if (smallSbu != 0) {
			smallSbu = smallSbu + 1;
        }
        remarkStr += "小扣：" + smallSbu + " ";
        //袖头扣
        String shirtScucellStr = cloudEntity.getModelScu();
        String scuCost = "0";
        if (!"".equals (shirtScucellStr)) {
            styleOption = returnUnitCost (sizeUnitCostList, ResourcesUtil.getConfig ("shirt_scu") + "-" + shirtScucellStr);
            if (styleOption != null) {
                scuCost = styleOption.getMaterialUnitCost ();
            }
        }
        //前身长
        String shirtYunLengthcellStr = cloudEntity.getSizeYunLen();
        //前立
        String shirtSfpcellStr = cloudEntity.getModelSfp();
        //前立扣数
        int sfpCost = 0;
        //余数
        double sfpCostRem = 0;
        if (!"".equals (shirtYunLengthcellStr)) {
        	//如果前立为4FPA00、4FPC00、4FPB35或4FPB25，按照原来算法计算大扣。
        	//如果前立为4FPPOL，则前立扣数为2，其它的前立扣数为4。
        	//如果前立为4FPC00、4FPD00、4FPG00或4FPF00，则有4颗金属扣。
        	//$原来算法:前立扣数 = (前身长-5.5)/9 向下取整，如果(前身长-5.5)%9小于6，则减1。
        	if ("4FPD00,4FPG00,4FPF00,4FPPOP".indexOf(shirtSfpcellStr) != -1) {
    			sfpCost = 4;
				if ("4FPD00,4FPG00,4FPF00".indexOf(shirtSfpcellStr) != -1) {
					metalSbu = 4;
				}
			}else if ("4FPPOL".equals(shirtSfpcellStr)){
				sfpCost = 2;
			}else {
				sfpCost = (int)Math.floor((Double.parseDouble(shirtYunLengthcellStr)-5.5)/9);
				sfpCostRem = (Double.parseDouble(shirtYunLengthcellStr)-5.5)%9;
				if (sfpCostRem < 6) {
					sfpCost = sfpCost - 1;
				}
				/*if ("4FPC00".equals(shirtSfpcellStr)) {
					metalSbu = 4;
				}*/
			}
        }
        bigSbu = bigSbu + (int)Double.parseDouble(scuCost) + sfpCost;
        if (bigSbu != 0) {
            bigSbu = bigSbu + 1;
            remarkStr += "大扣：" + bigSbu;
        }
        if (metalSbu != 0) {
        	remarkStr += " 金属扣：" + metalSbu;
		}
        cloudEntity.setSizeBof(sfpCost + "");
        map.put("bigSbu", bigSbu);
        map.put("smallSbu", smallSbu);
        map.put("sfpCost", sfpCost);
        map.put("remarkStr", remarkStr);
        map.put("scoCost", (int)Double.parseDouble(scoCost));
		return map;
	}
    
    /**
     * 扣眼数的计算
     *
     * @param cloudEntity
     * @param sizeUnitCostList
     * @return
     */
    public int countBHNum(StyleDesignHistoryEntity cloudEntity,List<StyleOptionEntity> sizeUnitCostList) {
    	//扣眼数
    	int bHNum = 0;
    	//领子
        String shirtScocellStr = cloudEntity.getModelSco();
        //袖头
        String shirtScucellStr = cloudEntity.getModelScu();
        //袖开祺
        String shirtSvvcellStr = cloudEntity.getModelSsv();
        //前立
        String shirtSfpcellStr = cloudEntity.getModelSfp();
        //前立扣数
        String shirtBofcellStr = cloudEntity.getSizeBof();
        if ("".equals(cloudEntity.getSampleFlag())) {
        	bHNum = bHNum + (int)Double.parseDouble(shirtBofcellStr);
		}else {
			bHNum = 0;
		}
        for (StyleOptionEntity styleOption : sizeUnitCostList) {
            if (styleOption.getItemValue ().equals (shirtScocellStr) || 
            	styleOption.getItemValue ().equals (shirtScucellStr) ||
            	styleOption.getItemValue ().equals (shirtSvvcellStr) ||
            	styleOption.getItemValue ().equals (shirtSfpcellStr)) {
            	if (styleOption != null) {
            		bHNum = bHNum + (int)Double.parseDouble(styleOption.getHoleCost());
                }
			}
        }
        return bHNum;
    }
    
    /**
     * 获取费用
     *
     * @param designOptionsList
     * @param cellStr
     * @return
     */
    public String returnCost(List <DesignOption> designOptionsList, String cellStr) {

        for (DesignOption designOption : designOptionsList) {
            if (designOption.getItemValue ().equals (cellStr.trim ())) {
                if (designOption.getItemCost () == null || designOption.getItemCost ().compareTo(new BigDecimal(0)) == 0) {
                    return "0";
                }
                return designOption.getItemCost ().toString ();
            }
        }
        return "0";
    }
    
    /**
     * cell值转换
     *
     * @param val
     * @return
     */
    public String valuechange(String val) {

        // 获取当前的cell值
        if (val == null || "".equals (val.trim ()) || "-".equals (val.trim ())) {
            return "";
        } else {
            String[] arryVal = val.split ("/");
            if (arryVal.length > 1) {
                return arryVal[0].replace(".", "").trim ();
            }
        }
        return val.trim ();
    }
    
    /**
     * 获取费用
     *
     * @param sizeUnitCost
     * @return
     */
    public StyleOptionEntity returnUnitCost(List <StyleOptionEntity> sizeUnitCost, String costStr) {

        for (StyleOptionEntity styleOption : sizeUnitCost) {
            if ((styleOption.getItemCode () + "-" + styleOption.getItemValue ()).equals (costStr)) {

                return styleOption;
            }
        }
        return null;
    }
    
    /**
     * 获取品控信息
     *
     * @param qualityControlList
     * @param itemCode
     * @param itemValue
     * @return
     */
    public String returnQCInfo(List <StyleOptionEntity> qualityControlList, String itemCode, String itemValue) {

        for (StyleOptionEntity styleOption : qualityControlList) {
            if ((styleOption.getItemCode () + "-" + styleOption.getItemValue ()).equals (itemCode + "-" + itemValue)) {
                return styleOption.getQcItem ();
            }
        }
        return "";
    }
    
    /**
     * 获取SC品控信息
     *
     * @param qualityControlList
     * @param itemCode
     * @return
     */
    public String returnSCQCInfo(List <StyleOptionEntity> qualityControlList, String itemValue) {

        for (StyleOptionEntity styleOption : qualityControlList) {
            if (styleOption.getItemValue ().equals (itemValue)) {
                return styleOption.getQcItem ();
            }
        }
        return "";
    }
    
    /**
     * cell值转换(量体项目值转换)
     *
     * @param val
     * @return
     */
    public String valuechangeInt(String val) {
        // 获取当前的cell值
        if (val == null || "".equals (val.trim ()) || "-".equals (val.trim ())) {
            return "-";
        } else {
            String[] arryVal = val.split ("\\(");
            if (arryVal.length > 1) {
                return arryVal[0];
            }
        }
        return val;
    }
    
    /**
     * 获取客户列表
     * @return
     */
    public List<Ognization> findCustomList(){
    	return orderDao.findCustomList();
    }
    
    /**
     * 检查订单号是否存在
     * @return
     */
    public Order checkOrderExist(String orderNo){
    	orderNo = orderNo.replace(".", ",");
    	orderNo = orderNo.split(",")[orderNo.split(",").length-1];
    	Order order = orderDao.checkOrderExist(orderNo);
    	return order;
    }
    
    /**
     * 更新订单信息
     * @return
     */
    public void updateOrderData(List<Order> orderList,String fileFlag)throws Exception{
    	if (orderList!=null&&orderList.size()>0) {
    		if ("NORMAL_ENCHASE".equals(fileFlag)) {
    			for(Order order:orderList){
    				if (order!=null) {
    					// 订单装箱信息未导入（0）或导入过初始信息（1）
    					if (order.getCartonInfoStatus() == 0 || order.getCartonInfoStatus() == 1) {
    						//设置装箱信息导入状态为初始信息
    						order.setCartonInfoStatus(1);
    					// 订单装箱信息导入过补充信息（2）或全部导入（3）
						}else if (order.getCartonInfoStatus() == 2 || order.getCartonInfoStatus() == 3) {
							//设置装箱信息导入状态为全部导入
							order.setCartonInfoStatus(3);
						}
    					order.preUpdate();
    					orderDao.updateNormalOrderData(order);
    				}
    			}
			}else if ("SUPPLEMENT_ENCHASE".equals(fileFlag)) {
				for(Order order:orderList){
					if (order!=null) {
						order.preUpdate();
						//吊牌数据处理，不显示中文
						String hangStr = orderDao.getHangtagByOrderID(order);
						if (hangStr != null) {
							hangStr = hangStr.replace("/", ",").split(",")[0];
						}
						// 订单装箱信息未导入（0）或导入过补充信息（2）
						if (order.getCartonInfoStatus() == 0 || order.getCartonInfoStatus() == 2) {
							//设置装箱信息导入状态为补充信息
    						order.setCartonInfoStatus(2);
    					// 订单装箱信息导入过初始信息（1）或全部导入（3）
						}else if (order.getCartonInfoStatus() == 1 || order.getCartonInfoStatus() == 3) {
							//设置装箱信息导入状态为全部导入
							order.setCartonInfoStatus(3);
						}
						order.setHangtag(hangStr);
						orderDao.updateSupplementOrderData(order);
						orderDao.updateSupplementDataByOrderNo(order);
					}
				}
			}
    		/*//获取定制合同信息
    		CustomizationContract contract = orderDao.getContractID(orderList.get(0).getId());
    		//装箱信息未完整
    		if (contract.getCartonInfoStatus() == 0) {
    			//初始装箱信息和补充装箱信息都未导入过
    			if (ResourcesUtil.getConfig("enchaseInfo_complete_none").equals(contract.getRemarks())) {
    				//当次导入的是初始装箱信息
    				if ("NORMAL_ENCHASE".equals(fileFlag)) {
    					contract.setCartonInfoStatus(0);
    					contract.setRemarks(ResourcesUtil.getConfig("enchaseInfo_complete_normal"));
    				//当次导入的是补充装箱信息
					}else if ("SUPPLEMENT_ENCHASE".equals(fileFlag)) {
						contract.setCartonInfoStatus(0);
						contract.setRemarks(ResourcesUtil.getConfig("enchaseInfo_complete_supplement"));
					}
    			//导入过初始装箱信息或补充装箱信息其中之一
    			}else if ((ResourcesUtil.getConfig("enchaseInfo_complete_normal").equals(contract.getRemarks()) && "SUPPLEMENT_ENCHASE".equals(fileFlag))
    					|| (ResourcesUtil.getConfig("enchaseInfo_complete_supplement").equals(contract.getRemarks()))) {
    				contract.setCartonInfoStatus(1);
    				contract.setRemarks(ResourcesUtil.getConfig("enchaseInfo_complete_all"));
    			}
			}
    		contract.preInsert();
    		//更新定制合同相关信息
			orderDao.updateCustomContract(contract);*/
		}
    }
    
    
    
    //------------------------------------------定制合同------------------------------------------------//
    
    /**
	 * 查询父项
	 * @param page
	 * @return
	 */
    public Page<CustomizationContract> findCustomizationContractList(Page<CustomizationContract> page, CustomizationContract customizationContract) {
        // 生成数据权限过滤条件（dsf为dataScopeFilter的简写，在xml中使用 ${sqlMap.dsf}调用权限SQL）
        //designOption.getSqlMap().put("dsf", dataScopeFilter(user.getCurrentUser(), "o", "a"));
        // 设置分页参数
    	customizationContract.setPage(page);
        // 执行分页查询
        page.setList(orderDao.findContractList(customizationContract));
        return page;
    }
    
    /**
	 * 获取一条信息
	 * 
	 * @param user
	 * @return
	 */
    public CustomizationContract getContractInfo(Long contractId){
    	return orderDao.getContractInfo(contractId);
    }

    /**
     * 更新标识
     * @return
     */
    public void  updateUrgentCd(String urgentCD,String orderNO) throws Exception{

        orderDao.updateUrgentCd(urgentCD,orderNO);
    }
    /**
     * 更新标识
     * @return
     */
    public void  updateTempOorderByOrderNO(String urgentCD,String orderNO) throws Exception{

        orderDao.updateTempOorderByOrderNO(urgentCD,orderNO);
    }

    
    /**
     * 更新状态
     * @return
     */
    public String  updateStatus(Order order) throws Exception{
    	String flag = "";
    	List<Order> orders = orderDao.findList(order);
		if (orders!=null&&orders.size()>0) {
			for (Order order2 : orders) {
				order2.setOrderStatusUS(order.getOrderStatusUS());
				order2.setTargetDateStr(order.getTargetDateStr());
				order2.setUrgentCD(order.getUrgentCD());
				order2.preInsert();
				orderDao.updateStatus(order2);
				orderDao.updateStatusTemp(order2);
			}
			flag = "true";
		}else {
			flag = "cloud";
		}
		return flag;
    }


	public OrderListShowEntity getOrderInfo(String styleId) {
		return orderDao.getOrderInfo(styleId);
	}
	
	public List<OrderListShowEntity> getShirtStyle(String styleId) {
		List<OrderListShowEntity> shirtStyle = orderDao.getShirtStyle(styleId);
		List<OrderListShowEntity> tempList = new ArrayList<OrderListShowEntity>();
		OrderListShowEntity tempEntity = new OrderListShowEntity();
		StyleFitEntity styleFitEntity = styleFitEntityMapper.getFit(Long.parseLong(styleId));
		if (styleFitEntity != null) {
			String[] fitItemValue = styleFitEntity.getItemValue().split(",");
			String[] fitValue = styleFitEntity.getFitValue().split(",");
			for (int i = 0; i < fitItemValue.length; i++) {
				tempEntity.setStyleQualityControlEntity(new StyleQualityControlEntity());
				tempEntity.getStyleQualityControlEntity().setQcItemValue(fitItemValue[i]);
				tempEntity.getStyleQualityControlEntity().setQcItemRealValue(fitValue[i]);
				tempList.add(tempEntity);
				tempEntity = new OrderListShowEntity();
			}
			shirtStyle.addAll(tempList);
		}
		return shirtStyle;
	}
	
	public void stopImport() {
		stopFlag = true;
	}
	
	
	/**
	 * 获取合同费用明细数据
	 * @param contractNo
	 * @return
	 */
	public List<ExportCostEntity> findContractCostDetails(String contractNo){
		// 全部设计点数据集
		List <DesignOption> designOptionsList = findDesignOption (new Order());
		// 数据载体实体对象
		StyleDesignHistoryEntity cloudEntity = new StyleDesignHistoryEntity();
		// 导出实体对象
		ExportCostEntity exportCostEntity = new ExportCostEntity();
		// 导出数据集合对象
		List<ExportCostEntity> exportCostList = new ArrayList<ExportCostEntity>();
		// 根据合同号获取合同信息
		ContractCustomEntity contractCustomEntity = contractCustomEntityMapper.getByCode(contractNo);
		if (contractCustomEntity != null) {
			// 根据合同id获取合同订单关联数据
			List<ContractCustomOrderEntity> contractCustomOrderList = contractCustomOrderEntityMapper.findListByContractId(contractCustomEntity.getContractId());
			if (contractCustomOrderList != null) {
				for(ContractCustomOrderEntity cEntity : contractCustomOrderList){
					// 获取订单数据
					OrderEntity orderEntity = orderEntityMapper.get(cEntity.getOrderId());
					if (orderEntity != null) {
						// 获取款式数据
						StyleEntity styleEntity = styleEntityMapper.getStyle(orderEntity.getStyleId().longValue());
						// 获取款式量体数据
						StyleFitEntity styleFitEntity = styleFitEntityMapper.getFit(orderEntity.getStyleId().longValue());
						// 获取款式设计点数据
						List<StyleOptionREntity> styleOptionList = styleOptionEntityMapper.findAllList(orderEntity.getStyleId().longValue());
						// map集合
						Map<String,String> tempMap = new HashMap<String,String>();
						// 遍历放入map集合中
						for(StyleOptionREntity sEntity : styleOptionList){
							// 若为扣，则设置扣数
							if (ResourcesUtil.getConfig ("shirt_sbu").equals(sEntity.getItemValue())) {
								tempMap.put(sEntity.getItemValue(), String.valueOf(sEntity.getOptionCost().intValue()));
							}else {
								tempMap.put(sEntity.getItemValue(), sEntity.getOptionValue());
							}
						}
						// 设置数据载体
						cloudEntity = setOptionData(styleEntity,tempMap,styleFitEntity);
						// 设置订单号
						cloudEntity.setOrderNo(orderEntity.getOrderNo());
						// 获取导出数据
						exportCostEntity = getExportCostInfo(cloudEntity,designOptionsList,styleEntity.getStyleComposition(),styleEntity.getMaterialStyle());
						// 放入集合
						exportCostList.add(exportCostEntity);
					}
					// 实例化
					cloudEntity = new StyleDesignHistoryEntity();
					exportCostEntity = new ExportCostEntity();
				}
			}
			// 返回数据集
			return exportCostList;
		}
		// 无数据返回null
		return null;
	}
	
	/**
	 * 设置数据载体
	 * @param styleEntity
	 * @param optionMap
	 * @param styleFitEntity
	 * @return
	 */
	public StyleDesignHistoryEntity setOptionData(StyleEntity styleEntity,Map<String,String> optionMap,StyleFitEntity styleFitEntity){
		// 实体对象
		StyleDesignHistoryEntity cloudEntity = new StyleDesignHistoryEntity();
        // 物料号
        cloudEntity.setFabricCode(styleEntity.getSytleFabricNo());
        // 缝制方式
        cloudEntity.setModelSma(optionMap.get(ResourcesUtil.getConfig ("shirt_4sma")));
        // 款式中文名
        cloudEntity.setStyleNameCn(styleEntity.getStyleNameCn());
        // 缝制线
        cloudEntity.setTrimThdno(optionMap.get(ResourcesUtil.getConfig ("shirt_thread")));
        // 线号
        cloudEntity.setTrimSgd(optionMap.get(ResourcesUtil.getConfig ("shirt_sgd")));
        // 扣数
        cloudEntity.setTrimSbu(optionMap.get(ResourcesUtil.getConfig ("shirt_sbu")));
        // 袖子
        cloudEntity.setModelSsl(optionMap.get(ResourcesUtil.getConfig ("shirt_ssl")));
        // 领子
        cloudEntity.setModelSco(optionMap.get(ResourcesUtil.getConfig ("shirt_sco")));
        // 袖头
        cloudEntity.setModelScu(optionMap.get(ResourcesUtil.getConfig ("shirt_scu")));
        // 订扣
        cloudEntity.setTrimSat(optionMap.get(ResourcesUtil.getConfig ("shirt_sat")));
        // 袖开祺
        cloudEntity.setModelSsv(optionMap.get(ResourcesUtil.getConfig ("shirt_ssv")));
        // 订扣线颜色
        cloudEntity.setTrimSbh(optionMap.get(ResourcesUtil.getConfig ("shirt_sbh_colour")));
        cloudEntity.setTrimSbt(optionMap.get(ResourcesUtil.getConfig ("shirt_sbt_colour")));
        // 衬布 (新版没有衬布钱)
        cloudEntity.setModelSsk(optionMap.get(ResourcesUtil.getConfig ("shirt_ssk")));
        // 领子，袖头配色线
        cloudEntity.setTrimSts(optionMap.get(ResourcesUtil.getConfig ("shirt_sts_colour")));
        // 领插签
        cloudEntity.setModelSbo(optionMap.get(ResourcesUtil.getConfig ("shirt_sbo")));
        // 台领下夹牙绳
        cloudEntity.setTrimSbi(optionMap.get(ResourcesUtil.getConfig ("shirt_sbi")));
        // 前立
        cloudEntity.setModelSfp(optionMap.get(ResourcesUtil.getConfig ("shirt_sfp")));
        // 胸兜
        cloudEntity.setModelSbp(optionMap.get(ResourcesUtil.getConfig ("shirt_sbp")));
        // 后背款式
        cloudEntity.setModelSba(optionMap.get(ResourcesUtil.getConfig ("shirt_sba")));
        // 水洗要求
        cloudEntity.setModelWash(optionMap.get(ResourcesUtil.getConfig ("shirt_washed")));
        // 领子，袖口明线
        cloudEntity.setModelSst(optionMap.get(ResourcesUtil.getConfig ("shirt_sst")));
        // 包装方法
        cloudEntity.setModelSpck(optionMap.get(ResourcesUtil.getConfig ("shirt_packaging")));
        // 手绢
        cloudEntity.setModelSpo(optionMap.get(ResourcesUtil.getConfig ("shirt_spo")));
        // Ribbon
        cloudEntity.setModelRibb(optionMap.get(ResourcesUtil.getConfig ("shirt_ribbon")));
        // 后省
        cloudEntity.setModelSbd(optionMap.get(ResourcesUtil.getConfig ("shirt_sbd")));
        // 过肩
        cloudEntity.setModelSbj(optionMap.get(ResourcesUtil.getConfig ("shirt_sbj")));
        // 底摆款式
        cloudEntity.setModelSbs(optionMap.get(ResourcesUtil.getConfig ("shirt_sbs")));
        // 小号
        cloudEntity.setLablSize(optionMap.get(ResourcesUtil.getConfig ("shirt_sizelabel")));
        // 台领里配料
        cloudEntity.setContSc1(optionMap.get(ResourcesUtil.getConfig ("shirt_contrast_sc1")));
        // 后领中订商标
        cloudEntity.setLablLp1(optionMap.get(ResourcesUtil.getConfig ("shirt_slc_lp01")));
        // 羽领，台领配料
        cloudEntity.setContSc2(optionMap.get(ResourcesUtil.getConfig ("shirt_contrast_sc2")));
        // 三角布
        cloudEntity.setLablLp2(optionMap.get(ResourcesUtil.getConfig ("shirt_slc_lp02")));
        // 袖头里配料
        cloudEntity.setContSc3(optionMap.get(ResourcesUtil.getConfig ("shirt_contrast_sc3")));
        // 上前立里侧订商标
        cloudEntity.setLablLp3(optionMap.get(ResourcesUtil.getConfig ("shirt_slc_lp03")));
        // 袖头配料
        cloudEntity.setContSc4(optionMap.get(ResourcesUtil.getConfig ("shirt_contrast_sc4")));
        // 下前立里侧订商标
        cloudEntity.setLablLp4(optionMap.get(ResourcesUtil.getConfig ("shirt_slc_lp04")));
        // 台领配料
        cloudEntity.setContSc5(optionMap.get(ResourcesUtil.getConfig ("shirt_contrast_sc5")));
        // 大布订商标
        cloudEntity.setLablLp5(optionMap.get(ResourcesUtil.getConfig ("shirt_slc_lp05")));
        // 上前立表配料
        cloudEntity.setContSc6(optionMap.get(ResourcesUtil.getConfig ("shirt_contrast_sc6")));
        // 后领缝商标
        cloudEntity.setLablLp6(optionMap.get(ResourcesUtil.getConfig ("shirt_slc_lp06")));
        // 下前立配料
        cloudEntity.setContSc7(optionMap.get(ResourcesUtil.getConfig ("shirt_contrast_sc7")));
        // 吊牌
        cloudEntity.setLablHas(optionMap.get(ResourcesUtil.getConfig ("shirt_hangtag")));
        // 袖补强布配料
        cloudEntity.setContSc8(optionMap.get(ResourcesUtil.getConfig ("shirt_contrast_sc8")));
        // 洗涤成分
        cloudEntity.setLablCl(optionMap.get(ResourcesUtil.getConfig ("shirt_carelabel")));
        // 手绢配料
        cloudEntity.setContSc9(optionMap.get(ResourcesUtil.getConfig ("shirt_contrast_sc9")));
        // Care label type
        cloudEntity.setLablClt(optionMap.get(ResourcesUtil.getConfig ("shirt_labeltype")));
        // 大布配料
        cloudEntity.setContSc0(optionMap.get(ResourcesUtil.getConfig ("shirt_contrast_sc0")));
        // 产地标
        cloudEntity.setLablCoo(optionMap.get(ResourcesUtil.getConfig ("shirt_country")));
        // 刺绣内容
        cloudEntity.setEmbrText(optionMap.get(ResourcesUtil.getConfig ("4smt")));
        // 量体数据
        String[] itemValueList = styleFitEntity.getItemValue().split(",");
        String[] fitValueList = styleFitEntity.getFitValue().split(",");
        for (int i = 0; i < itemValueList.length; i++) {
        	//左袖头围左
			if ("CIRCU_ITEM_17".equals(itemValueList[i])) {
				cloudEntity.setSizeCll(fitValueList[i]);
			//右袖头围右
			}else if ("CIRCU_ITEM_18".equals(itemValueList[i])) {
				cloudEntity.setSizeClr(fitValueList[i]);
			//左袖长
			}else if ("POSTU_ITEM_07".equals(itemValueList[i])) {
				cloudEntity.setSizeSll(fitValueList[i]);
			//右袖长
			}else if ("POSTU_ITEM_09".equals(itemValueList[i])) {
				cloudEntity.setSizeSlr(fitValueList[i]);
			//左肩高
			}else if ("CIRCU_ITEM_19".equals(itemValueList[i])) {
				cloudEntity.setSizeLsl(fitValueList[i]);
			//右肩高
			}else if ("CIRCU_ITEM_21".equals(itemValueList[i])) {
				cloudEntity.setSizeLsr(fitValueList[i]);
			}
		}
        //
		return cloudEntity;
	}
	
	/**
	 * 获取费用数据供导出Excel使用
	 * @param cloudEntity
	 * @param designOptionsList
	 * @return
	 */
    public ExportCostEntity getExportCostInfo(StyleDesignHistoryEntity cloudEntity,List <DesignOption> designOptionsList,String materialComposition,String materialStyle){
    	// 服装款式费用实体类
    	ExportCostEntity exportCostEntity = new ExportCostEntity();
    	// 初始总金额为0元
    	BigDecimal amount = new BigDecimal(0);
    	// 订单号
    	exportCostEntity.setOrderNo(cloudEntity.getOrderNo());
    	// 数量
    	exportCostEntity.setQuantity("1");
    	// 面料号
    	exportCostEntity.setFabricCode(cloudEntity.getFabricCode());
    	// 开始配料计算，空串赋0
        if (exportCostEntity.getContrast() == null || "".equals(exportCostEntity.getContrast())) {
    		exportCostEntity.setContrast("0");
		}
        //--------------------------------------------------------------------------------------------------------------- //
        //---------------------------------------------------需修正---start------------------------------------------------//
        //--------------------------------------------------------------------------------------------------------------- //
        //斜纹
        if (ResourcesUtil.getConfig ("material_style_twill").equals(materialStyle)) {
        	exportCostEntity.setTwillFabric(ResourcesUtil.getConfig ("material_twill_cost"));
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("material_twill_cost")));
        //对格
        } else if (ResourcesUtil.getConfig ("material_style_grid").equals(materialStyle)) {
        	exportCostEntity.setCheck(ResourcesUtil.getConfig ("material_grid_cost"));
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("material_grid_cost")));
        //对条
        } else if (ResourcesUtil.getConfig ("material_style_strip").equals(materialStyle)) {
        	exportCostEntity.setStripy(ResourcesUtil.getConfig ("material_strip_cost"));
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("material_strip_cost")));
        }
        // 凡是针织面料
        if (cloudEntity.getFabricCode().toUpperCase().indexOf("KNIT") != -1 
    			|| ResourcesUtil.getConfig ("knit_other_fabric").indexOf(cloudEntity.getFabricCode().toUpperCase()) != -1) {
        	exportCostEntity.setSpecialFabric(ResourcesUtil.getConfig ("spec_composition_cost"));
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("spec_composition_cost")));
        	exportCostEntity.setWaterWash(ResourcesUtil.getConfig ("headStr_knit_cost"));
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("headStr_knit_cost")));
         //特殊面料
        } else if ("4CALB-100CO,100%棉,100%CO,100CO".indexOf(materialComposition) == -1) {
        	exportCostEntity.setSpecialFabric(ResourcesUtil.getConfig ("spec_composition_cost"));
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("spec_composition_cost")));
        }
        //--------------------------------------------------------------------------------------------------------------- //
        //---------------------------------------------------需修正---end--------------------------------------------------//
        //--------------------------------------------------------------------------------------------------------------- //
        // 新版
        if ("新版衬衫".equals(cloudEntity.getStyleNameCn().trim()) && cloudEntity.getModelSma().indexOf("BM") == -1) {
        	exportCostEntity.setNewPattern(ResourcesUtil.getConfig ("new_shirt_cost"));
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("new_shirt_cost")));
        }
        // 缝制方式
        String makeType = ResourcesUtil.getConfig ("shirt_4sma") + "-" + cloudEntity.getModelSma().trim ();
        if (cloudEntity.getModelSma().indexOf("4M") != -1 || cloudEntity.getModelSma().indexOf("SM") != -1) {
            if ("新版衬衫".equals(cloudEntity.getStyleNameCn().trim())) {
            	exportCostEntity.setCMPrice(ResourcesUtil.getConfig ("new_traditonal"));
            	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("new_traditonal")));
            } else {
            	exportCostEntity.setCMPrice(ResourcesUtil.getConfig ("old_traditonal"));
            	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("old_traditonal")));
            }
        } else if (cloudEntity.getModelSma().indexOf("4H") != -1 || cloudEntity.getModelSma().indexOf("SH") != -1) {
            String getCost = returnCost (designOptionsList, cloudEntity.getModelSma());
            exportCostEntity.setCMPrice(getCost);
            amount = amount.add(new BigDecimal(getCost));
        } else if (cloudEntity.getModelSma().indexOf("BM") != -1) {
        	exportCostEntity.setCMPrice(ResourcesUtil.getConfig ("bm_traditonal"));
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("bm_traditonal")));
        }
        // 缝制线
        if (cloudEntity.getTrimThdno().indexOf("G0008") != -1  || cloudEntity.getTrimThdno().indexOf("K403") != -1) {
        	exportCostEntity.setWhite("3");
        	amount = amount.add(new BigDecimal(3));
        } else {
        	exportCostEntity.setWhite("4");
        	amount = amount.add(new BigDecimal(4));
        }
        // 线号
        String getCost = returnCost (designOptionsList, cloudEntity.getTrimSgd());
        if (!"0".equals (getCost)) {
            if ("4GDCA".equals (cloudEntity.getTrimSgd())) {
            	exportCostEntity.setThreadThikness(getCost);
            	amount = amount.add(new BigDecimal(getCost));
            }
        }
        //袖子
        if ("4SLLO2".equals(cloudEntity.getModelSsl().replace(".", ""))) {
        	//机缝
        	if (makeType.equals (ResourcesUtil.getConfig ("make_type_4m")) || makeType.equals (ResourcesUtil.getConfig ("make_type_sm")) || makeType.equals (ResourcesUtil.getConfig ("make_type_bm"))) {
        		exportCostEntity.setSleeveCuffPolyfold("6");
        		amount = amount.add(new BigDecimal(4));
        	//手缝
        	} else if (makeType.equals (ResourcesUtil.getConfig ("make_type_sh")) || makeType.equals (ResourcesUtil.getConfig ("make_type_4h"))) {
        		exportCostEntity.setSleeveCuffPolyfold("8");
        		amount = amount.add(new BigDecimal(8));
        	}
		}
        // 领尖暗扣 
        if (cloudEntity.getModelSco().indexOf("4COBB") != -1) {
        	exportCostEntity.setButtonInsideCollar("4");
        	amount = amount.add(new BigDecimal(4));
        }
        //袖头(大袖头)
        //机缝 3.6元
        if (makeType.equals (ResourcesUtil.getConfig ("make_type_4m")) || makeType.equals (ResourcesUtil.getConfig ("make_type_sm"))  || makeType.equals (ResourcesUtil.getConfig ("make_type_bm"))) {
            if (cloudEntity.getModelScu().indexOf ("DR7") != -1 || cloudEntity.getModelScu().indexOf ("DH7") != -1 
            		|| cloudEntity.getModelScu().indexOf ("SM7") != -1 || cloudEntity.getModelScu().indexOf ("DS7") != -1
            		|| cloudEntity.getModelScu().indexOf ("NA7") != -1) {
                exportCostEntity.setCuff("3.6");
                amount = amount.add(new BigDecimal(3.6));
            }
        //手缝 4.8元
        } else if (makeType.equals (ResourcesUtil.getConfig ("make_type_sh")) || makeType.equals (ResourcesUtil.getConfig ("make_type_4h"))) {
            if (cloudEntity.getModelScu().indexOf ("DR7") != -1 || cloudEntity.getModelScu().indexOf ("DH7") != -1 
            		|| cloudEntity.getModelScu().indexOf ("SM7") != -1 || cloudEntity.getModelScu().indexOf ("DS7") != -1
            		|| cloudEntity.getModelScu().indexOf ("NA7") != -1) {
            	exportCostEntity.setCuff("4.8");
            	amount = amount.add(new BigDecimal(4.8));
            	// 手缝大袖头扣眼，全手缝大袖头时，收4.8元
            	exportCostEntity.setHmDubbleCuffHole("4.8");
            	amount = amount.add(new BigDecimal(4.8));
            }
        }
        //订扣
        /*getCost = returnCost (designOptionsList, cloudEntity.getTrimSat());
        if (!"0".equals (getCost)) {
            
        }*/
        //袖开祺
        /*getCost = returnCost (designOptionsList, cloudEntity.getModelSsv());
        if (!"0".equals (getCost)) {
            
        }*/
        // 订扣线颜色
        if (!"G0008".equals (cloudEntity.getTrimSbh()) && !"K403".equals (cloudEntity.getTrimSbh()) && !"G0008".equals (cloudEntity.getTrimSbt()) && !"K403".equals (cloudEntity.getTrimSbt())) {
            if (!cloudEntity.getTrimSbh().equals (cloudEntity.getTrimSbt())) {
            	exportCostEntity.setSbtColorButtonattachment("4");
            	amount = amount.add(new BigDecimal(4));
            	exportCostEntity.setSbhColorButtonholes("4");
            	amount = amount.add(new BigDecimal(4));
            } else if (cloudEntity.getTrimSbh().equals (cloudEntity.getTrimSbt())) {
            	exportCostEntity.setSbhColorButtonholes("4");
            	amount = amount.add(new BigDecimal(4));
            }
        } else if (!"G0008".equals (cloudEntity.getTrimSbh()) && !"K403".equals (cloudEntity.getTrimSbh()) && ("G0008".equals (cloudEntity.getTrimSbt()) || "K403".equals (cloudEntity.getTrimSbt()))) {
        	exportCostEntity.setSbhColorButtonholes("4");
        	amount = amount.add(new BigDecimal(4));
        } else if (!"G0008".equals (cloudEntity.getTrimSbt()) && !"K403".equals (cloudEntity.getTrimSbt()) && ("G0008".equals (cloudEntity.getTrimSbh()) || "K403".equals (cloudEntity.getTrimSbh()))) {
        	exportCostEntity.setSbtColorButtonattachment("4");
        	amount = amount.add(new BigDecimal(4));
        }
        // 衬布 (新版没有衬布钱)
        getCost = returnCost (designOptionsList, cloudEntity.getModelSsk());
        if (!"0".equals (getCost)) {
            if (cloudEntity.getStyleNameCn().indexOf("OLD") != -1) {
            	exportCostEntity.setInterlining(getCost);
            	amount = amount.add(new BigDecimal(getCost));
            }
        }
        
        // 扣
        exportCostEntity.setButton(cloudEntity.getTrimSbu());
        // 手拿扣
        String btnCost = String.valueOf(new BigDecimal(cloudEntity.getTrimSbu()).multiply(new BigDecimal(0.15)).divide(new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP));
        exportCostEntity.setHandButton(btnCost);
        amount = amount.add(new BigDecimal(btnCost));
        // 领子，袖头配色线
        if (cloudEntity.getTrimSts().indexOf("A") == 0) {
        	exportCostEntity.setStsColorTopStitching("5");
        	amount = amount.add(new BigDecimal(5));
        } else if (cloudEntity.getTrimSts().indexOf("T") == 0) {
            if (!cloudEntity.getTrimThdno().equals (cloudEntity.getTrimSts().substring (1, cloudEntity.getTrimSts().length () - 1).trim ())) {
            	exportCostEntity.setStsColorTopStitching("4");
            	amount = amount.add(new BigDecimal(4));
            }
        }
        // 领插签
        /*getCost = returnCost (designOptionsList, cloudEntity.getModelSbo());
        if (!"0".equals (getCost)) {
        
        }*/
        // 台领下夹牙绳
        if (cloudEntity.getTrimSbi() != null && !"".equals (cloudEntity.getTrimSbi().trim()) && !"-".equals (cloudEntity.getTrimSbi().trim())) {
        	exportCostEntity.setSbiColorBiesCollar(ResourcesUtil.getConfig ("bies_collar_cost"));
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("bies_collar_cost")));
        }
        // 前立
    	// 当前立显示网状配料礼服（4FPG00）或者聚褶配料礼服（4FPF00）时，配料收5块钱
        if ("4FPG00,4FPF00,".indexOf(cloudEntity.getModelSfp()) != -1) {
        	exportCostEntity.setContrast((new BigDecimal (5).add(new BigDecimal (exportCostEntity.getContrast()))).toString());
        	amount = amount.add(new BigDecimal(5));
        }
        // 当前立为半开口前立，且面料不为针织面料，套头衫收15元，否则不收钱。
        if ("4FPPOP,".indexOf(cloudEntity.getModelSfp()) != -1) {
        	if (cloudEntity.getFabricCode().toUpperCase().indexOf("KNIT") != -1 
        			|| ResourcesUtil.getConfig ("knit_other_fabric").indexOf(cloudEntity.getFabricCode().toUpperCase()) != -1) {
        		exportCostEntity.setPopover("15");;
        		amount = amount.add(new BigDecimal(15));
            }
        }
        // 胸兜
        /*getCost = returnCost (designOptionsList, cloudEntity.getModelSbp());
        if (!"0".equals (getCost)) {
        	
        }*/
        // 后背款式
        /*getCost = returnCost (designOptionsList, cloudEntity.getModelSba());
        if (!"0".equals (getCost)) {
        	
        }*/
        // 水洗要求
        if (!"4WANO".equals (cloudEntity.getModelWash()) && !"".equals (cloudEntity.getModelWash())) {
        	exportCostEntity.setFabricCost(ResourcesUtil.getConfig ("washed_cost"));
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("washed_cost")));
        }
        // 领子，袖口明线
        /*getCost = returnCost (designOptionsList, cloudEntity.getModelSst());
        if (!"0".equals (getCost)) {
        	
        }*/
        // 包装方法
        /*getCost = returnCost (designOptionsList, cloudEntity.getModelSpck());
        if (!"0".equals (getCost)) {
        	
        }*/
        //薄纸
        getCost = returnCost (designOptionsList, ResourcesUtil.getConfig ("packaging_tissue"));
        exportCostEntity.setPaper(getCost);
        amount = amount.add(new BigDecimal(getCost));
        //印号
        getCost = returnCost (designOptionsList, ResourcesUtil.getConfig ("packaging_mark"));
        exportCostEntity.setPrint(getCost);
        amount = amount.add(new BigDecimal(getCost));
        // Ribbon
        if ("".equals(cloudEntity.getModelRibb()) || "无丝带,NO/无,NO / 无,".indexOf(cloudEntity.getModelRibb().toUpperCase()) == -1) {
        	exportCostEntity.setRibbon("0.3");
        	amount = amount.add(new BigDecimal(0.3));
		}
        // 后省
        /*getCost = returnCost (designOptionsList, cloudEntity.getModelSbd());
        if (!"0".equals (getCost)) {
        	
        }*/
        // 过肩
        /*getCost = returnCost (designOptionsList, cloudEntity.getModelSbj());
        if (!"0".equals (getCost)) {
            
        }*/
        // 底摆款式
        /*getCost = returnCost (designOptionsList, cloudEntity.getModelSbs());
        if (!"0".equals (getCost)) {
            
        }*/
        // 小号
        /*getCost = returnCost (designOptionsList, cloudEntity.getLablSize());
        if (!"0".equals (getCost)) {
            
        }*/
        // 台领里配料
        if (!"".equals (cloudEntity.getContSc1())) {
        	exportCostEntity.setContrast((new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")).add(new BigDecimal (exportCostEntity.getContrast()))).toString());
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("sc_contrast")));
        }
        // 后领中订商标
        /*getCost = returnCost (designOptionsList, cloudEntity.getLablLp1());
        if (!"0".equals (getCost)) {
            
        }*/
        // 羽领，台领配料
        if (!"".equals (cloudEntity.getContSc2())) {
        	exportCostEntity.setContrast((new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")).add(new BigDecimal (exportCostEntity.getContrast()))).toString());
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("sc_contrast")));
        }
        // 三角布
        /*getCost = returnCost (designOptionsList, cloudEntity.getLablLp2());
        if (!"0".equals (getCost)) {
            
        }*/
        //  袖头里配料
        if (!"".equals (cloudEntity.getContSc3())) {
        	exportCostEntity.setContrast((new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")).add(new BigDecimal (exportCostEntity.getContrast()))).toString());
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("sc_contrast")));
        }
        // 上前立里侧订商标
        /*getCost = returnCost (designOptionsList, cloudEntity.getLablLp3());
        if (!"0".equals (getCost)) {
            
        }*/
        // 袖头配料
        if (!"".equals (cloudEntity.getContSc4())) {
        	exportCostEntity.setContrast((new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")).add(new BigDecimal (exportCostEntity.getContrast()))).toString());
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("sc_contrast")));
        }
        // 下前立里侧订商标
        /*getCost = returnCost (designOptionsList, cloudEntity.getLablLp4());
        if (!"0".equals (getCost)) {
            
        }*/
        // 台领配料
        if (!"".equals (cloudEntity.getContSc5())) {
        	exportCostEntity.setContrast((new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")).add(new BigDecimal (exportCostEntity.getContrast()))).toString());
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("sc_contrast")));
        }
        // 大布订商标
        /*getCost = returnCost (designOptionsList, cloudEntity.getLablLp5());
        if (!"0".equals (getCost)) {
            
        }*/
        // 上前立表配料
        if (!"".equals (cloudEntity.getContSc6())) {
        	exportCostEntity.setContrast((new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")).add(new BigDecimal (exportCostEntity.getContrast()))).toString());
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("sc_contrast")));
        }
        // 后领缝商标
        /*getCost = returnCost (designOptionsList, cloudEntity.getLablLp6());
        if (!"0".equals (getCost)) {
            
        }*/
        // 下前立配料
        if (!"".equals (cloudEntity.getContSc7())) {
        	exportCostEntity.setContrast((new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")).add(new BigDecimal (exportCostEntity.getContrast()))).toString());
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("sc_contrast")));
        }
        // 吊牌
        /*getCost = returnCost (designOptionsList, cloudEntity.getLablHas());
        if (!"0".equals (getCost)) {
            
        }*/
        // 袖补强布配料
        if (!"".equals (cloudEntity.getContSc8())) {
        	exportCostEntity.setContrast((new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")).add(new BigDecimal (exportCostEntity.getContrast()))).toString());
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("sc_contrast")));
        }
        // 洗涤成分
        /*getCost = returnCost (designOptionsList, cloudEntity.getLablCl());
        if (!"0".equals (getCost)) {
            
        }*/
        // 手绢配料
        if (!"".equals (cloudEntity.getContSc9())) {
        	// 手绢
    		//机缝 2.2元
    		if (makeType.equals (ResourcesUtil.getConfig ("make_type_4m")) || makeType.equals (ResourcesUtil.getConfig ("make_type_sm")) || makeType.equals (ResourcesUtil.getConfig ("make_type_bm"))) {
    			exportCostEntity.setPochet(ResourcesUtil.getConfig ("pochet_traditonal"));
    			amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("pochet_traditonal")));
    			//手缝 11元
    		} else if (makeType.equals (ResourcesUtil.getConfig ("make_type_sh")) || makeType.equals (ResourcesUtil.getConfig ("make_type_4h"))) {
    			exportCostEntity.setPochet(ResourcesUtil.getConfig ("pochet_handmade"));
    			amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("pochet_handmade")));
    		}
    		// 若不为本料则收2元配料钱
    		if (!cloudEntity.getFabricCode().equals (cloudEntity.getContSc9())) {
    			exportCostEntity.setContrast((new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")).add(new BigDecimal (exportCostEntity.getContrast()))).toString());
    			amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("sc_contrast")));
    		}
        }
        // Care label type
        /*getCost = returnCost (designOptionsList, cloudEntity.getLablClt());
        if (!"0".equals (getCost)) {
            
        }*/
        // 大布配料
        if (!"".equals (cloudEntity.getContSc0())) {
        	exportCostEntity.setContrast((new BigDecimal (ResourcesUtil.getConfig ("sc_contrast")).add(new BigDecimal (exportCostEntity.getContrast()))).toString());
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("sc_contrast")));
        }
        // 产地标
        /*getCost = returnCost (designOptionsList, cloudEntity.getLablCoo());
        if (!"0".equals (getCost)) {
            
        }*/
        // 刺绣内容
        if (!"".equals (cloudEntity.getEmbrText())) {
        	exportCostEntity.setEmbroidery(ResourcesUtil.getConfig ("embroidery_text"));
        	amount = amount.add(new BigDecimal(ResourcesUtil.getConfig ("embroidery_text")));
        }
        //左袖头围左 ≠ 右袖头围右
        if (!"".equals (cloudEntity.getSizeClr())) {
        	if ((new BigDecimal(cloudEntity.getSizeCll())).compareTo(new BigDecimal(cloudEntity.getSizeClr())) != 0) {
        		exportCostEntity.setCuffLength("1.65");
        		amount = amount.add(new BigDecimal(1.65));
        	} 
		}
        //左袖长 ≠ 右袖长
        if (!"".equals (cloudEntity.getSizeSlr())) {
	        if ((new BigDecimal(cloudEntity.getSizeSll())).compareTo(new BigDecimal(cloudEntity.getSizeSlr())) != 0) {
	        	exportCostEntity.setSleeveLength("1.65");
	        	amount = amount.add(new BigDecimal(1.65));
	        }
        }
        //左肩高≠ 右肩高
        if (!"".equals (cloudEntity.getSizeSlr())) {
        	if ((new BigDecimal(cloudEntity.getSizeLsl())).compareTo(new BigDecimal(cloudEntity.getSizeLsr())) != 0) {
        		exportCostEntity.setLowShoulder("1.65");
        		amount = amount.add(new BigDecimal(1.65));
        	}
        }
        // 总计
        exportCostEntity.setAmount(String.valueOf(amount.doubleValue()));
        //
        return exportCostEntity;
    }
    
    /**
     * 导入订单费用
     * @param orderList
     * @return
     */
    public String saveOrderCost(List<Order> orderList) throws Exception{
    	Order order = new Order();
    	for(Order entity :orderList){
    		// 检验订单是否存在
    		order = checkOrderExist(entity.getOrderNO());
			if (order==null) {
				// 不存在返回当前订单号
				return entity.getOrderNO();
			}
			if ("".equals(entity.getStrCost())) {
				// 费用为空返回当前订单号
				return entity.getOrderNO();
			}
			// 设置费用
			order.setStrCost(entity.getStrCost()+" $");
			// 更新款式备注（订单费用）
			orderDao.updateStyleRemarks(order);
		}
    	// 成功返回字符
    	return "IMPORT_SUCCESS";
    }

}
